---
title: "Partisan Dehumanization"
author: "David Samuels and Karine Belarmino"
date: "`r Sys.Date()`"
output:
  html_document:
    self_contained: no
    toc: yes
    number_sections: yes
    code_folding: hide
    toc_float:
      collapsed: no
      smooth_scroll: no
  pdf_document:
    toc: yes
  word_document:
    toc: yes
editor_options: 
  chunk_output_type: console
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev = 'png',
                     dpi = 300)

setwd("~/Desktop/Summer 2022/Partisan Dehumanization")

library(foreign)
library(ggplot2)
library(dplyr)
library(haven)
library(survey)
library(jtools)
library(remotes)
#library(svrepmisc)
library(magick)
library(car)
library(lm.beta)#standardized coefficients
library(interactions) #johnson newman figure
library(emmeans) #interactions
options(stringsAsFactors = F)         # no automatic data transformation
options("scipen" = 100000000, "digits" = 5) # suppress scientific notation
# install packages
library(knitr)
library(lattice)
library(tidyverse)
library(likert) # for creating a likert plot
library(MASS)
library(psych)
library(viridis)
library(here)
library(flextable)
library(devtools)
library(rmarkdown)
library(kableExtra) # make nice looking output tables
library(dotwhisker)
library(patchwork)
require(ggiraph) #ggPredict
require(ggiraphExtra)
require(plyr)
library(ggpubr)
library(ggeffects)
library(broom)
library(scales)
library(ltm)
library(Hmisc)
library(polycor)
library(psycho)
library(stargazer) #for tables
library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(psych)
library(gtsummary)
library(corrplot)
library(vtable)
library(ggcorrplot)
library(caret)
library(lubridate)
library(pwr) #power analysis to calculate how many valid responses we need so the experiments are valid
library(ggeffects)
#library(apsrtable) can't install it
```

# 2nd Survey Analysis of the 5th batch - run from May 2,2023 to May 6, 2023 - 
dataset exported from qualtrics on May 8, 2023

## Cleaning dataset - getting rid of outliers.

```{r, include=F}
#calling original dataset:
main <- read.csv("Dehumanization main - Dec 22_May 7, 2023_11.42.csv", header=T)
#variables' names
names(main)
#removing rows with column titles:
main <- main[-c(1,2),]
summary(main)
table(main$Finished)
#1593 participants began the survey
#982 participants finished the survey 
##(62% of respondents)


#Remove higher end outliers on "total duration of survey" variable:
#Using boxplot stats to do so:
summary(as.numeric(main$Duration..in.seconds.))
#mean 563s (9.4 min)
main$Duration..in.seconds. <- as.numeric(main$Duration..in.seconds.)
boxplot(main$Duration..in.seconds., horizontal=T)
boxplot.stats(main$Duration..in.seconds.)
main2 <- subset(main, Duration..in.seconds.<=1328)
boxplot(main2$Duration..in.seconds., horizontal=T)
boxplot.stats(main2$Duration..in.seconds.)
main3 <- subset(main2, Duration..in.seconds.<1257)
boxplot(main3$Duration..in.seconds., horizontal=T)
boxplot.stats(main3$Duration..in.seconds.)
main4 <- subset(main3, Duration..in.seconds.<1243)
boxplot(main4$Duration..in.seconds., horizontal=T)
boxplot.stats(main4$Duration..in.seconds.)
summary(main4$Duration..in.seconds.)


#Outliers on the lower end:
#removing observations that completed the survey under 4.7 min 
#(half of the mean):
main5 <- subset(main4, Duration..in.seconds.>282)
summary(main5$Duration..in.seconds.)
#participants with valid responses: 1108
#average time: 9.97 min

#After removing outliers, 79% (870 out of 1108) of respondents finished the survey
table(main5$Finished)
#we have 870 valid responses with finished surveys


#rename dataset so the code chunks below run:
main <- main5

#changing empty cells into NA
main[main == ""] <- NA


#power analysis - One-way ANOVA (https://ladal.edu.au/pwr.html)
##how many petistas, antipetistas and nonpartisans we should have to have valid responses:
###k=number of groups
###f=effect size
###sig.level= alpha
###power= Cohen (1988) strong
###pwr::pwr.anova.test(k=3, f=0.5, sig.level=0.01, power=0.8)
#20 participants in each group 




```

## Statistics for and translation of variables of interest

Checking frequencies of control variables:

```{r statistics, include=F}
table(main$Age)
prop.table(table(main$Age))

table(main$Region)
prop.table(table(main$Region))
table(main$Educ)
prop.table(table(main$Educ))
table(main$Gender)
prop.table(table(main$Gender))
table(main$Race)
prop.table(table(main$Race))
table(main$HHIncome)
prop.table(table(main$HHIncome))


#translating controls for tables:

main$Region[main$Region=="Centro-Oeste"] <- "Midwest"
main$Region[main$Region=="Nordeste"] <- "Northeast"
main$Region[main$Region=="Norte"] <- "North"
main$Region[main$Region=="Sudeste"] <- "Southeast"
main$Region[main$Region=="Sul"] <- "South"
table(main$Region)
main$Gender[main$Gender=="Homem"] <- "Man"
main$Gender[main$Gender=="Mulher"] <- "Woman"
table(main$Gender)
main$Race[main$Race=="Amarelo"] <- "Yellow"
main$Race[main$Race=="Branco"] <- "White"
main$Race[main$Race=="Índio"] <- "Indigenous"
main$Race[main$Race=="Não Sabe"] <- "Does not know"
main$Race[main$Race=="Pardo"] <- "Brown"
main$Race[main$Race=="Preto"] <- "Black"
table(main$Race)
main$Educ[main$Educ=="Pós-graduação"] <- "Grad School"
main$Educ[main$Educ=="Primário"] <- "Elementary School"
main$Educ[main$Educ=="Primeiro grau/ensino fundamental"] <- "Middle School"
main$Educ[main$Educ=="Segundo grau"] <- "High School"
main$Educ[main$Educ=="Universitário"] <- "College"
table(main$Educ)
```

## Creating Dummies for the Independent Variables of Interest - petistas, 
antipetistas, non-partisans

Non-petistas who voted for lula and non-antipetistas who votes for Bolsonaro

We decided that pure antipartisans and antipartisans should be a single 
variable "antipartisans."

```{r variablesofinterest, include=F}
#creating dummies for variables of interest:
main$Petistas <- 0
main$Petistas[main$PartyLike=="PT - Partido dos Trabalhadores"] <- 1
prop.table(table(main$Petistas))
## 18% are petistas
##198 petistas


#Antipetistas (Samuels and Zucco: antipetistas + pure antipetistas) -  
#PartyDislike = PT
main$Antipetistas <- 0
main$Antipetistas[main$PartyDislike=="PT - Partido dos Trabalhadores"] <- 1
prop.table(table(main$Antipetistas))
## 37% are antipetistas
##409 antipetistas
#proportion of antipetistas who like any other political party:
prop.table(table(main$Antipetistas,main$PartyLike))
0.0135+0.0463+0.00386+0.326+0.0212+0.0154+0.00579
#0.43
#75% of antipetistas who identify with a political party, like PL.


#############
# pure antipetistas)   
#PartyDislike = PT, Party
prop.table(table(main$PosPartisan))
prop.table(table(main$PartyDislike))
main$pureAntipetistas <- 0
main$pureAntipetistas[main$PosPartisan=="Não"& main$PartyDislike=="PT - Partido dos Trabalhadores"] <- 1
prop.table(table(main$pureAntipetistas))

#pl antipetistas
#PartyDislike = PT, PartyLike: PL

main$plAntipetistas <- 0
main$plAntipetistas[main$PartyLike=="PL - Partido Liberal"& main$PartyDislike=="PT - Partido dos Trabalhadores"] <- 1
prop.table(table(main$plAntipetistas))


#Lulistas (voted for Lula + Petistas==0 + Antipetistas==0)
main$Lulistas <- ifelse(main$Petistas==0 & main$Antipetistas==0 & main$Q80=="Lula", 1, 0)
prop.table(table(main$Lulistas)) #18%

#Bolsonaristas (voted for Bolsonaro + Petistas==0 +Antipetistas==0)
main$Bolsonaristas <- ifelse(main$Petistas==0 & main$Antipetistas==0 & main$Q80=="Jair Bolsonaro", 1, 0)
prop.table(table(main$Bolsonaristas))#10%


#Nonpartisans - PosPartisan - Nao and NegPartisan = Nao (old codification)
main$NonPartisans <- 0
main$NonPartisans[main$PosPartisan=="Não" & main$NegPartisan=="Não"] <- 1
prop.table(table(main$NonPartisans))
## 17% are nonpartisans (192 respondents)

#Nonpartisans2 (neither Lulistas or Bolsonaristas)
main$NonPartisans2 <- ifelse(main$NonPartisans==1 & main$Q80!=c("Lula", "Jair Bolsonaro"), 1, 0)
prop.table(table(main$NonPartisans2)) #12%




main$PL <- 0
main$PL[main$PartyDislike=="PT - Partido dos Trabalhadores" & 
          main$PartyLike=="PL - Partido Liberal"] <- 1
prop.table(table(main$PL))
#15% are antipetistas and like for PL
#169 antipetistas like PL (41% dos antipetistas)




#comparing the Cohen power of our analysis with the number of responses we have: 
pwr::pwr.anova.test(k=5, power=.8, sig.level=0.01, f=0.25)
#good enough for analysis with the entire sample (no experimental conditions taken into account)

```


## Calculating Partisan Identity Strength Standardized Composites

```{r partisanintensity, include=F}
#recoding strings into factors and change levels - 
#Most negative (lower values) to most positive (higher levels)
#relevel Antipetismo1 categories: Voce se considera um(a) antipetista?
table(main$Antipetismo1)
main$f.Antipetismo1 <- factor(main$Antipetismo1, levels=c("Não", 
                                                          "Um pouco",
                                                          "Sim","Muito"))
summary(as.numeric(main$f.Antipetismo1))

### AntiPetismo3 - Pessoas proximas o (a) descrevem como antiPetistas?
#1=Sempre, 2=Frequentemente, 3=Raramente, 4=Nunca
table(main$Antipetismo3)
main$f.Antipetismo3 <- factor(main$Antipetismo3, levels=c("Nunca","Raramente",                                                         "Frequentemente", "Sempre"))
summary(as.numeric(main$f.Antipetismo3))


### AntiPetismo5 - Quando você se refere aos antagonistas do PT, 
### com que frequência você usa o pronome “nós” ao invés do pronome “eles”?
table(main$Antipetismo5)
main$f.Antipetismo5 <- factor(main$Antipetismo5, levels=c("Nunca", "Raramente", 
                                                          "Frequentemente", 
                                                          "Sempre"))
summary(as.numeric(main$f.Antipetismo5))


#Alpha Cronbach: internal consistency
a.antipetismo <- main %>% select(f.Antipetismo1,
                                 f.Antipetismo3,
                                 f.Antipetismo5)%>%na.omit()
cronbach.alpha(a.antipetismo, CI=T)
#alpha: 0.63 [0.56, 0.69]

##### Identity strength composity for antipetistas: 
main$comp.Antipetismo<-(as.numeric(main$f.Antipetismo1)+
                           as.numeric(main$f.Antipetismo3)+
                           as.numeric(main$f.Antipetismo5))/3
summary(main$comp.Antipetismo)

main$s.comp.Antipetismo <- rescale(main$comp.Antipetismo, to = c(-1, 1))
summary(main$s.comp.Antipetismo)

#recoding strings into factors and change levels - 
#Most negative (lower values) to most positive (higher levels)
#rename petismo1 categories: Voce se considera um(a) petista?
table(main$Petismo1)
main$f.Petismo1 <- factor(main$Petismo1, levels=c("Não", "Um pouco",
                                                  "Sim","Muito"))
summary(as.numeric(main$f.Petismo1))

### Petismo3 - Pessoas proximas o (a) descrevem como Petistas?
#1=Sempre, 2=Frequentemente, 3=Raramente, 4=Nunca
table(main$Petismo3)
main$f.Petismo3 <- factor(main$Petismo3, levels=c("Nunca","Raramente", 
                                                  "Frequentemente", "Sempre"))
summary(as.numeric(main$f.Petismo3))

### Petismo5 - Quando você se refere aos simpatizantes do PT, 
### com que frequência você usa o pronome “nós” ao invés do pronome “eles”?
table(main$Petismo5)
main$f.Petismo5 <- factor(main$Petismo5, levels=c("Nunca", "Raramente", 
                                                  "Frequentemente", "Sempre"))
summary(as.numeric(main$f.Petismo5))

#Alpha Cronbach: internal consistency
a.petismo <- main %>% select(f.Petismo1, f.Petismo3, f.Petismo5)%>%na.omit()
cronbach.alpha(a.petismo, CI=T)
#alpha = 0.75 [0.66, 0.82]

##### Initial Identity strength composity for petistas:
main$comp.Petismo<-(as.numeric(main$f.Petismo1)+
                      as.numeric(main$f.Petismo3)+
                      as.numeric(main$f.Petismo5))/3
summary(main$comp.Petismo)

main$s.comp.Petismo <- rescale(main$comp.Petismo, to = c(-1, 1))
summary(main$s.comp.Petismo)

```

## Subtle Dehumanization against Petistas

Calculating the subtle dehumanization composites against petistas and running 
non-standardized OLS models on the effects of partisanship on subtle 
(mechanistic and animalistic) dehumanization against petistas.

Observations:

1.  RECODE SUBTLE DEHUMANIZATION OF PETISTAS:"SubtleDehumPT_1-22", 
skiping 9 and 10
2.  "Page.Submit" variable does not appear for SubtleDehumPT\_ as it 
does for SubtleDehumAntiPT\_? 
3. HUMANIZED (muito agressivo) to MOST deHUMANIZED (nem um pouco agressivo) TO MAKE IT CONSISTENT WITH THE 
BLATANT DEHUMANIZATION MEASURES.
4.  Attention!! The function "level" used below contains the order of the 
categories.
5.  Some variables are reverse-coded due to the meaning of the qualifiers.

```{r function_DehumAgainstPetistas, include=F}
#Dehumanization against petistas: 

#Mechanistic traits (Cassesse): intenso, divertido, 
#curioso, sociavel, trusting, invejoso, nervoso, 
#impaciente, distraido, and agressivo 

#SubtleDehumPT_1 - Agressivo
table(main$SubtleDehumPT_1)
main$f.SubtleDehumPT_1 <- factor(main$SubtleDehumPT_1, 
                                 levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_1)
summary(as.numeric(main$f.SubtleDehumPT_1))
#SubtleDehumPT_4 - Curioso
table(main$SubtleDehumPT_4)
main$f.SubtleDehumPT_4 <- factor(main$SubtleDehumPT_4, 
                                 levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", 
                                          "Muito"))
summary(main$f.SubtleDehumPT_4)
summary(as.numeric(main$f.SubtleDehumPT_4))
#SubtleDehumPT_5 - Distraido
table(main$SubtleDehumPT_5)
main$f.SubtleDehumPT_5 <- factor(main$SubtleDehumPT_5, 
                                 levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_5)
summary(as.numeric(main$f.SubtleDehumPT_5))
#SubtleDehumPT_6 - Divertido
table(main$SubtleDehumPT_6)
main$f.SubtleDehumPT_6 <- factor(main$SubtleDehumPT_6, 
                                 levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", 
                                          "Muito"))
summary(main$f.SubtleDehumPT_6)
summary(as.numeric(main$f.SubtleDehumPT_6))
#SubtleDehumPT_11 - Impaciente
table(main$SubtleDehumPT_11)
main$f.SubtleDehumPT_11 <- factor(main$SubtleDehumPT_11, 
                                  levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_11)
summary(as.numeric(main$f.SubtleDehumPT_11))
#SubtleDehumPT_12 - Pouco Amigável
table(main$SubtleDehumPT_12)
main$f.SubtleDehumPT_12 <- factor(main$SubtleDehumPT_12, 
                                  levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_12)
summary(as.numeric(main$f.SubtleDehumPT_12))
#SubtleDehumPT_13 - Invejoso
table(main$SubtleDehumPT_13)
main$f.SubtleDehumPT_13 <- factor(main$SubtleDehumPT_13, 
                                  levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_13)
summary(as.numeric(main$f.SubtleDehumPT_13))
#SubtleDehumPT_14 - Nervoso
table(main$SubtleDehumPT_14)
main$f.SubtleDehumPT_14 <- factor(main$SubtleDehumPT_14, 
                                  levels=c("Muito", "Um pouco", "Muito pouco", 
                                          "Nem um pouco"))
summary(main$f.SubtleDehumPT_14)
summary(as.numeric(main$f.SubtleDehumPT_14))
#SubtleDehumPT_16 - Intenso - NEGATIVE?
table(main$SubtleDehumPT_16)
main$f.SubtleDehumPT_16 <- factor(main$SubtleDehumPT_16, 
                                  levels=c("Muito", "Um pouco", 
                                           "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_16)
summary(as.numeric(main$f.SubtleDehumPT_16))
#SubtleDehumPT_19 - Sociavel
table(main$SubtleDehumPT_19)
main$f.SubtleDehumPT_19 <- factor(main$SubtleDehumPT_19, 
                                  levels=c("Nem um pouco", "Muito pouco", 
                                           "Um pouco", 
                                          "Muito"))
summary(main$f.SubtleDehumPT_19)
summary(as.numeric(main$f.SubtleDehumPT_19))

#Alpha Cronbach: internal consistency
a.SubtleMechDehumPT <- main %>% select(f.SubtleDehumPT_1, f.SubtleDehumPT_4, 
                                       f.SubtleDehumPT_5, f.SubtleDehumPT_6, 
                                       f.SubtleDehumPT_11, f.SubtleDehumPT_12, f.SubtleDehumPT_13, f.SubtleDehumPT_14, f.SubtleDehumPT_16, 
                                       f.SubtleDehumPT_19)%>%na.omit()
cronbach.alpha(a.SubtleMechDehumPT, CI=T)
#alpha = 0.83 [0.82, 0.85]

#subtle mechanistic dehumanization against petistas indicator:
main$comp.SubtleMechDehumPT <- (as.numeric(main$f.SubtleDehumPT_1)+
                                as.numeric(main$f.SubtleDehumPT_4)+
                                  as.numeric(main$f.SubtleDehumPT_5)+
                                  as.numeric(main$f.SubtleDehumPT_6)+
                                  as.numeric(main$f.SubtleDehumPT_11)+
                                  as.numeric(main$f.SubtleDehumPT_12)+
                                  as.numeric(main$f.SubtleDehumPT_13)+
                                  as.numeric(main$f.SubtleDehumPT_14)+
                                  as.numeric(main$f.SubtleDehumPT_16)+
                                  as.numeric(main$f.SubtleDehumPT_19))/10
summary(main$comp.SubtleMechDehumPT)

#humanization (-1) to dehumanization (1):
main$s.comp.SubtleMechDehumPT <- rescale(main$comp.SubtleMechDehumPT, 
                                         to = c(1, -1))
summary(main$s.comp.SubtleMechDehumPT)


#Cassesse: Animalistic traits included: humilde, 
#meticuloso, organizado, educado, cabeca-aberta, frio, 
#superficial, ingenuo, mesquinho, and insensivel 
#SubtleDehumPT_2 - Cabeca-Aberta
table(main$SubtleDehumPT_2)
main$f.SubtleDehumPT_2 <- factor(main$SubtleDehumPT_2, 
                                 levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", "Muito"))

summary(main$f.SubtleDehumPT_2)
summary(as.numeric(main$f.SubtleDehumPT_2))
#SubtleDehumPT_3 - Frio
table(main$SubtleDehumPT_3)
main$f.SubtleDehumPT_3 <- factor(main$SubtleDehumPT_3, 
                                 levels=c("Muito", "Um pouco", 
                                          "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_3)
summary(as.numeric(main$f.SubtleDehumPT_3))
#SubtleDehumPT_7 - Insensivel
table(main$SubtleDehumPT_7)
main$f.SubtleDehumPT_7 <- factor(main$SubtleDehumPT_7, 
                                 levels=c("Muito", "Um pouco", 
                                          "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_7)
summary(as.numeric(main$f.SubtleDehumPT_7))
#SubtleDehumPT_8 - Humilde - POSITIVE OR NEGATIVE? Coded as positive por now. 
table(main$SubtleDehumPT_8)
main$f.SubtleDehumPT_8 <- factor(main$SubtleDehumPT_8, 
                                 levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", "Muito"))
summary(main$f.SubtleDehumPT_8)
summary(as.numeric(main$f.SubtleDehumPT_8))
#SubtleDehumPT_15 - Organizado
table(main$SubtleDehumPT_15)
main$f.SubtleDehumPT_15 <- factor(main$SubtleDehumPT_15, 
                                  levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", "Muito"))
summary(main$f.SubtleDehumPT_15)
summary(as.numeric(main$f.SubtleDehumPT_15))
#SubtleDehumPT_17 - Educado
table(main$SubtleDehumPT_17)
main$f.SubtleDehumPT_17 <- factor(main$SubtleDehumPT_17, 
                                  levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", "Muito"))
summary(main$f.SubtleDehumPT_17)
summary(as.numeric(main$f.SubtleDehumPT_17))
#SubtleDehumPT_18 - Superficial
table(main$SubtleDehumPT_18)
main$f.SubtleDehumPT_18 <- factor(main$SubtleDehumPT_18, 
                                  levels=c("Muito", "Um pouco", 
                                          "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_18)
summary(as.numeric(main$f.SubtleDehumPT_18))
#SubtleDehumPT_20 - Mesquinho
table(main$SubtleDehumPT_20)
main$f.SubtleDehumPT_20 <- factor(main$SubtleDehumPT_20, 
                                  levels=c("Muito", "Um pouco", 
                                          "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_20)
summary(as.numeric(main$f.SubtleDehumPT_20))
#SubtleDehumPT_21 - Meticuloso - NEGATIVE?
table(main$SubtleDehumPT_21)
main$f.SubtleDehumPT_21<- factor(main$SubtleDehumPT_21, 
                                 levels=c("Muito", "Um pouco", 
                                          "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumPT_21)
summary(as.numeric(main$f.SubtleDehumPT_21))
#SubtleDehumPT_22 - Ingenuo - NEGATIVE?
table(main$SubtleDehumPT_22)
main$f.SubtleDehumPT_22<- factor(main$SubtleDehumPT_22, 
                                 levels=c("Nem um pouco", "Muito pouco", 
                                          "Um pouco", "Muito"))
summary(main$f.SubtleDehumPT_22)
summary(as.numeric(main$f.SubtleDehumPT_22))

#Alpha Cronbach: internal consistency
a.SubtleAnimDehumPT <- main %>% select(f.SubtleDehumPT_2, f.SubtleDehumPT_3, 
                                       f.SubtleDehumPT_7, f.SubtleDehumPT_8, 
                                       f.SubtleDehumPT_15, f.SubtleDehumPT_17, f.SubtleDehumPT_18, f.SubtleDehumPT_20, f.SubtleDehumPT_21, 
                                       f.SubtleDehumPT_22)%>%na.omit()
cronbach.alpha(a.SubtleAnimDehumPT, CI=T)
#alpha = 0.86 [0.84, 0.87]

#subtle animalistic dehumanization against petistas indicator:
main$comp.SubtleAnimDehumPT <- (as.numeric(main$f.SubtleDehumPT_2)+
                                  as.numeric(main$f.SubtleDehumPT_3)+
                                  as.numeric(main$f.SubtleDehumPT_7)+
                                  as.numeric(main$f.SubtleDehumPT_8)+
                                  as.numeric(main$f.SubtleDehumPT_15)+
                                  as.numeric(main$f.SubtleDehumPT_17)+
                                  as.numeric(main$f.SubtleDehumPT_18)+
                                  as.numeric(main$f.SubtleDehumPT_20)+
                                  as.numeric(main$f.SubtleDehumPT_21)+
                                  as.numeric(main$f.SubtleDehumPT_22))/10
summary(main$comp.SubtleAnimDehumPT)

#humanization (-1) and dehumanization (1):
main$s.comp.SubtleAnimDehumPT <- rescale(main$comp.SubtleAnimDehumPT, 
                                         to = c(1, -1))
summary(main$s.comp.SubtleAnimDehumPT)


```

## Subtle Dehumanization against Antipetistas

Calculating the subtle dehumanization composites against antipetistas and 
running non-standardized OLS models on the effects of partisanship on subtle 
(mechanistic and animalistic) dehumanization against antipetistas.

Observations:

1.  Most humanized (Muito agressivo) to Most dehumanized 
2.  Attention!! The function "level" used below contains the order of the 
categories.
3.  Some variables are reverse-coded due to the meaning of the qualifiers.

```{r function_DehumAgainstAntipetistas, include=F}



#Mechanistic traits (Cassesse): intenso, divertido, 
#curioso, sociavel, trusting, invejoso, nervoso, 
#impaciente, distraido, and agressivo 
#SubtleDehumPT_1 - Agressivo
table(main$SubtleDehumAntiPT_1)
main$f.SubtleDehumAntiPT_1 <- factor(main$SubtleDehumAntiPT_1, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_1)
summary(as.numeric(main$f.SubtleDehumAntiPT_1))
#SubtleDehumPT_4 - Curioso
table(main$SubtleDehumAntiPT_4)
main$f.SubtleDehumAntiPT_4 <- factor(main$SubtleDehumAntiPT_4, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_4)
summary(as.numeric(main$f.SubtleDehumAntiPT_4))
#SubtleDehumPT_5 - Distraido
table(main$SubtleDehumAntiPT_5)
main$f.SubtleDehumAntiPT_5 <- factor(main$SubtleDehumAntiPT_5, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_5)
summary(as.numeric(main$f.SubtleDehumAntiPT_5))
#SubtleDehumPT_6 - Divertido
table(main$SubtleDehumAntiPT_6)
main$f.SubtleDehumAntiPT_6 <- factor(main$SubtleDehumAntiPT_6, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_6)
summary(as.numeric(main$f.SubtleDehumAntiPT_6))
#SubtleDehumPT_9 - Impaciente
table(main$SubtleDehumAntiPT_9)
main$f.SubtleDehumAntiPT_9 <- factor(main$SubtleDehumAntiPT_9, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_9)
summary(as.numeric(main$f.SubtleDehumAntiPT_9))
#SubtleDehumPT_10 - Pouco Amigável
table(main$SubtleDehumAntiPT_10)
main$f.SubtleDehumAntiPT_10 <- factor(main$SubtleDehumAntiPT_10, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_10)
summary(as.numeric(main$f.SubtleDehumAntiPT_10))
#SubtleDehumPT_11 - Invejoso
table(main$SubtleDehumAntiPT_11)
main$f.SubtleDehumAntiPT_11 <- factor(main$SubtleDehumAntiPT_11, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_11)
summary(as.numeric(main$f.SubtleDehumAntiPT_11))
#SubtleDehumPT_12 - Nervoso
table(main$SubtleDehumAntiPT_12)
main$f.SubtleDehumAntiPT_12 <- factor(main$SubtleDehumAntiPT_12, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_12)
summary(as.numeric(main$f.SubtleDehumAntiPT_12))
#SubtleDehumPT_14 - Intenso - NEGATIVE?
table(main$SubtleDehumAntiPT_14)
main$f.SubtleDehumAntiPT_14 <- factor(main$SubtleDehumAntiPT_14, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_14)
summary(as.numeric(main$f.SubtleDehumAntiPT_14))
#SubtleDehumPT_17 - Sociavel
table(main$SubtleDehumAntiPT_17)
main$f.SubtleDehumAntiPT_17 <- factor(main$SubtleDehumAntiPT_17, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_17)
summary(as.numeric(main$f.SubtleDehumAntiPT_17))

#Alpha Cronbach: internal consistency
a.SubtleMechDehumAntiPT <- main %>% select(f.SubtleDehumAntiPT_1, 
                                           f.SubtleDehumAntiPT_4, 
                                           f.SubtleDehumAntiPT_5, 
                                           f.SubtleDehumAntiPT_6, 
                                           f.SubtleDehumAntiPT_9, 
                                           f.SubtleDehumAntiPT_10,
                                           f.SubtleDehumAntiPT_11, 
                                           f.SubtleDehumAntiPT_12, 
                                           f.SubtleDehumAntiPT_14, f.SubtleDehumAntiPT_17)%>%na.omit()
cronbach.alpha(a.SubtleMechDehumAntiPT, CI=T)
#alpha = 0.84 [0.82, 0.86]

#subtle mechanical dehumanization against antipetistas indicator:
main$comp.SubtleMechDehumAntiPT <- (as.numeric(main$f.SubtleDehumAntiPT_1)+
                                      as.numeric(main$f.SubtleDehumAntiPT_4)+
                                      as.numeric(main$f.SubtleDehumAntiPT_5)+
                                      as.numeric(main$f.SubtleDehumAntiPT_6)+
                                      as.numeric(main$f.SubtleDehumAntiPT_9)+
                                      as.numeric(main$f.SubtleDehumAntiPT_10)+
                                      as.numeric(main$f.SubtleDehumAntiPT_11)+
                                      as.numeric(main$f.SubtleDehumAntiPT_12)+
                                      as.numeric(main$f.SubtleDehumAntiPT_14)+
                                      as.numeric(main$f.SubtleDehumAntiPT_17))/10
summary(main$comp.SubtleMechDehumAntiPT)

#humanization (-1) and humanization (1)
main$s.comp.SubtleMechDehumAntiPT <- rescale(main$comp.SubtleMechDehumAntiPT, 
                                             to = c(1, -1))
summary(main$s.comp.SubtleMechDehumAntiPT)

#Cassesse: Animalistic traits included: humilde, meticuloso,
#organizado, educado, cabeca-aberta, frio, superficial,
#ingenuo, mesquinho, and insensivel 
#SubtleDehumAntiPT_2 - Cabeca-Aberta
table(main$SubtleDehumAntiPT_2)
main$f.SubtleDehumAntiPT_2 <- factor(main$SubtleDehumAntiPT_2, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_2)
summary(as.numeric(main$f.SubtleDehumAntiPT_2))
#SubtleDehumPT_3 - Frio
table(main$SubtleDehumAntiPT_3)
main$f.SubtleDehumAntiPT_3 <- factor(main$SubtleDehumAntiPT_3, 
                                     levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_3)
summary(as.numeric(main$f.SubtleDehumAntiPT_3))
#SubtleDehumAntiPT_7 - Insensivel
table(main$SubtleDehumAntiPT_7)
main$f.SubtleDehumAntiPT_7 <- factor(main$SubtleDehumAntiPT_7, 
                                     levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_7)
summary(as.numeric(main$f.SubtleDehumAntiPT_7))
#SubtleDehumAntiPT_8 - Humilde - POSITIVE OR NEGATIVE? Coded as positive por now. 
table(main$SubtleDehumAntiPT_8)
main$f.SubtleDehumAntiPT_8 <- factor(main$SubtleDehumAntiPT_8, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_8)
summary(as.numeric(main$f.SubtleDehumAntiPT_8))
#SubtleDehumAntiPT_13 - Organizado
table(main$SubtleDehumAntiPT_13)
main$f.SubtleDehumAntiPT_13 <- factor(main$SubtleDehumAntiPT_13, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_13)
summary(as.numeric(main$f.SubtleDehumAntiPT_13))
#SubtleDehumAntiPT_15 - Educado
table(main$SubtleDehumAntiPT_15)
main$f.SubtleDehumAntiPT_15 <- factor(main$SubtleDehumAntiPT_15, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_15)
summary(as.numeric(main$f.SubtleDehumAntiPT_15))
#SubtleDehumAntiPT_16 - Superficial
table(main$SubtleDehumAntiPT_16)
main$f.SubtleDehumAntiPT_16 <- factor(main$SubtleDehumAntiPT_16, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_16)
summary(as.numeric(main$f.SubtleDehumAntiPT_16))
#SubtleDehumAntiPT_18 - Mesquinho
table(main$SubtleDehumAntiPT_18)
main$f.SubtleDehumAntiPT_18 <- factor(main$SubtleDehumAntiPT_18, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_18)
summary(as.numeric(main$f.SubtleDehumAntiPT_18))
#SubtleDehumAntiPT_19 - Meticuloso - NEGATIVE?
table(main$SubtleDehumAntiPT_19)
main$f.SubtleDehumAntiPT_19<- factor(main$SubtleDehumAntiPT_19, 
                                     levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumAntiPT_19)
summary(as.numeric(main$f.SubtleDehumAntiPT_19))
#SubtleDehumAntiPT_20 - Ingenuo - NEGATIVE?
table(main$SubtleDehumAntiPT_20)
main$f.SubtleDehumAntiPT_20<- factor(main$SubtleDehumAntiPT_20, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumAntiPT_20)
summary(as.numeric(main$f.SubtleDehumAntiPT_20))

#Alpha Cronbach: internal consistency
a.SubtleAnimDehumAntiPT <- main %>% select(f.SubtleDehumAntiPT_2, 
                                           f.SubtleDehumAntiPT_3, 
                                           f.SubtleDehumAntiPT_7, 
                                           f.SubtleDehumAntiPT_8, 
                                           f.SubtleDehumAntiPT_13,
                                           f.SubtleDehumAntiPT_15, 
                                           f.SubtleDehumAntiPT_16, 
                                           f.SubtleDehumAntiPT_18, 
                                           f.SubtleDehumAntiPT_19, f.SubtleDehumAntiPT_20)%>%na.omit()
cronbach.alpha(a.SubtleAnimDehumAntiPT, CI=T)
#alpha = 0.84 [0.82,0.85]

#subtle animalistic dehumanization against antipetistas indicator:
main$comp.SubtleAnimDehumAntiPT <- (as.numeric(main$f.SubtleDehumAntiPT_2)+
                                      as.numeric(main$f.SubtleDehumAntiPT_3)+
                                      as.numeric(main$f.SubtleDehumAntiPT_7)+
                                      as.numeric(main$f.SubtleDehumAntiPT_8)+
                                      as.numeric(main$f.SubtleDehumAntiPT_13)+
                                      as.numeric(main$f.SubtleDehumAntiPT_15)+
                                      as.numeric(main$f.SubtleDehumAntiPT_16)+
                                      as.numeric(main$f.SubtleDehumAntiPT_18)+
                                      as.numeric(main$f.SubtleDehumAntiPT_19)+
                                      as.numeric(main$f.SubtleDehumAntiPT_20))/10
summary(main$comp.SubtleAnimDehumAntiPT)

#humanization (-1) and dehumanization (1)
main$s.comp.SubtleAnimDehumAntiPT <- rescale(main$comp.SubtleAnimDehumAntiPT, 
                                             to = c(1, -1))
summary(main$s.comp.SubtleAnimDehumAntiPT)

```

## Subtle Dehumanization against Non-partisans

Calculating the subtle dehumanization composites against non-partisans and 
running non-standardized OLS models on the effects of partisanship on subtle 
(mechanistic and animalistic) dehumanization against non-partisans.

Observations:

1.  Most humanized (Muito agressivo) to Most dehumanized 
2.  Attention!! The function "level" used below contains the order of the 
categories.
3.  Some variables are reverse-coded due to the meaning of the qualifiers.

```{r function_DehumAgainstNonpartisans, include=F}


#Mechanistic traits (Cassesse): intenso, divertido, 
#curioso, sociavel, trusting, invejoso, nervoso, 
#impaciente, distraido, and agressivo 
#SubtleDehumNonPart_1 - Agressivo
table(main$SubtleDehumNonPart_1)
main$f.SubtleDehumNonPart_1 <- factor(main$SubtleDehumNonPart_1, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_1)
summary(as.numeric(main$f.SubtleDehumNonPart_1))
#SubtleDehumNonPart_4 - Curioso
table(main$SubtleDehumNonPart_4)
main$f.SubtleDehumNonPart_4 <- factor(main$SubtleDehumNonPart_4, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_4)
summary(as.numeric(main$f.SubtleDehumNonPart_4))
#SubtleDehumPT_5 - Distraido
table(main$SubtleDehumNonPart_5)
main$f.SubtleDehumNonPart_5 <- factor(main$SubtleDehumNonPart_5, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_5)
summary(as.numeric(main$f.SubtleDehumNonPart_5))
#SubtleDehumPT_6 - Divertido
table(main$SubtleDehumNonPart_6)
main$f.SubtleDehumNonPart_6 <- factor(main$SubtleDehumNonPart_6, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_6)
summary(as.numeric(main$f.SubtleDehumNonPart_6))
#SubtleDehumPT_9 - Impaciente
table(main$SubtleDehumNonPart_9)
main$f.SubtleDehumNonPart_9 <- factor(main$SubtleDehumNonPart_9, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_9)
summary(as.numeric(main$f.SubtleDehumNonPart_9))
#SubtleDehumPT_10 - Pouco Amigável
table(main$SubtleDehumNonPart_10)
main$f.SubtleDehumNonPart_10 <- factor(main$SubtleDehumNonPart_10, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_10)
summary(as.numeric(main$f.SubtleDehumNonPart_10))
#SubtleDehumPT_11 - Invejoso
table(main$SubtleDehumNonPart_11)
main$f.SubtleDehumNonPart_11 <- factor(main$SubtleDehumNonPart_11, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_11)
summary(as.numeric(main$f.SubtleDehumNonPart_11))
#SubtleDehumPT_12 - Nervoso
table(main$SubtleDehumNonPart_12)
main$f.SubtleDehumNonPart_12 <- factor(main$SubtleDehumNonPart_12, 
                                      levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_12)
summary(as.numeric(main$f.SubtleDehumNonPart_12))
#SubtleDehumPT_14 - Intenso - negative?
table(main$SubtleDehumNonPart_14)
main$f.SubtleDehumNonPart_14 <- factor(main$SubtleDehumNonPart_14, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_14)
summary(as.numeric(main$f.SubtleDehumNonPart_14))
#SubtleDehumPT_17 - Sociavel
table(main$SubtleDehumNonPart_17)
main$f.SubtleDehumNonPart_17 <- factor(main$SubtleDehumNonPart_17, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_17)
summary(as.numeric(main$f.SubtleDehumNonPart_17))

#Alpha Cronbach: internal consistency
a.SubtleMechDehumNonPart <- main %>% select(f.SubtleDehumNonPart_1, 
                                            f.SubtleDehumNonPart_4, 
                                            f.SubtleDehumNonPart_5, 
                                            f.SubtleDehumNonPart_6, 
                                            f.SubtleDehumNonPart_9, 
                                            f.SubtleDehumNonPart_10, 
                                            f.SubtleDehumNonPart_11, 
                                            f.SubtleDehumNonPart_12, 
                                            f.SubtleDehumNonPart_14, f.SubtleDehumNonPart_17)%>%na.omit()
cronbach.alpha(a.SubtleMechDehumNonPart, CI=T)
#alpha = 0.77 [0.73, 0.8]

#subtle mechanical dehumanization against antipetistas indicator:
main$comp.SubtleMechDehumNonPart <- (as.numeric(main$f.SubtleDehumNonPart_1)+
                                      as.numeric(main$f.SubtleDehumNonPart_4)+
                                      as.numeric(main$f.SubtleDehumNonPart_5)+
                                      as.numeric(main$f.SubtleDehumNonPart_6)+
                                      as.numeric(main$f.SubtleDehumNonPart_9)+
                                      as.numeric(main$f.SubtleDehumNonPart_10)+
                                      as.numeric(main$f.SubtleDehumNonPart_11)+
                                      as.numeric(main$f.SubtleDehumNonPart_12)+
                                      as.numeric(main$f.SubtleDehumNonPart_14)+
                                      as.numeric(main$f.SubtleDehumNonPart_17))/10
summary(main$comp.SubtleMechDehumNonPart)

# humanized (-1) to dehumaized (1)
main$s.comp.SubtleMechDehumNonPart <- rescale(main$comp.SubtleMechDehumNonPart, 
                                              to = c(1, -1))
summary(main$s.comp.SubtleMechDehumNonPart)

#Cassesse: Animalistic traits included: humilde, meticuloso,
#organizado, educado, cabeca-aberta, frio, superficial,
#ingenuo, mesquinho, and insensivel 
#SubtleDehumAntiPT_2 - Cabeca-Aberta
table(main$SubtleDehumNonPart_2)
main$f.SubtleDehumNonPart_2 <- factor(main$SubtleDehumNonPart_2, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_2)
summary(as.numeric(main$f.SubtleDehumNonPart_2))
#SubtleDehumPT_3 - Frio
table(main$SubtleDehumNonPart_3)
main$f.SubtleDehumNonPart_3 <- factor(main$SubtleDehumNonPart_3, 
                                     levels=c("Muito", "Um pouco", 
                                              "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_3)
summary(as.numeric(main$f.SubtleDehumNonPart_3))
#SubtleDehumAntiPT_7 - Insensivel
table(main$SubtleDehumNonPart_7)
main$f.SubtleDehumNonPart_7 <- factor(main$SubtleDehumNonPart_7, 
                                     levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_7)
summary(as.numeric(main$f.SubtleDehumNonPart_7))
#SubtleDehumAntiPT_8 - Humilde - Coded as positive por now. 
table(main$SubtleDehumNonPart_8)
main$f.SubtleDehumNonPart_8 <- factor(main$SubtleDehumNonPart_8, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_8)
summary(as.numeric(main$f.SubtleDehumNonPart_8))
#SubtleDehumAntiPT_13 - Organizado
table(main$SubtleDehumNonPart_13)
main$f.SubtleDehumNonPart_13 <- factor(main$SubtleDehumNonPart_13, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_13)
summary(as.numeric(main$f.SubtleDehumNonPart_13))
#SubtleDehumAntiPT_15 - Educado
table(main$SubtleDehumNonPart_15)
main$f.SubtleDehumNonPart_15 <- factor(main$SubtleDehumNonPart_15, 
                                      levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_15)
summary(as.numeric(main$f.SubtleDehumNonPart_15))
#SubtleDehumAntiPT_16 - Superficial
table(main$SubtleDehumNonPart_16)
main$f.SubtleDehumNonPart_16 <- factor(main$SubtleDehumNonPart_16, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_16)
summary(as.numeric(main$f.SubtleDehumNonPart_16))
#SubtleDehumAntiPT_18 - Mesquinho
table(main$SubtleDehumNonPart_18)
main$f.SubtleDehumNonPart_18 <- factor(main$SubtleDehumNonPart_18, 
                                      levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_18)
summary(as.numeric(main$f.SubtleDehumNonPart_18))
#SubtleDehumAntiPT_19 - Meticuloso - NEGATIVE?
table(main$SubtleDehumNonPart_19)
main$f.SubtleDehumNonPart_19<- factor(main$SubtleDehumNonPart_19, 
                                     levels=c("Muito", "Um pouco", 
                                               "Muito pouco", "Nem um pouco"))
summary(main$f.SubtleDehumNonPart_19)
summary(as.numeric(main$f.SubtleDehumNonPart_19))
#SubtleDehumAntiPT_20 - Ingenuo - NEGATIVE?
table(main$SubtleDehumNonPart_20)
main$f.SubtleDehumNonPart_20<- factor(main$SubtleDehumNonPart_20, 
                                     levels=c("Nem um pouco", "Muito pouco", 
                                              "Um pouco", "Muito"))
summary(main$f.SubtleDehumNonPart_20)
summary(as.numeric(main$f.SubtleDehumNonPart_20))


#Alpha Cronbach: internal consistency
a.SubtleAnimDehumNonPart <- main %>% select(f.SubtleDehumNonPart_2, 
                                            f.SubtleDehumNonPart_3, 
                                            f.SubtleDehumNonPart_7, 
                                            f.SubtleDehumNonPart_8, 
                                            f.SubtleDehumNonPart_13, 
                                            f.SubtleDehumNonPart_15, 
                                            f.SubtleDehumNonPart_16, 
                                            f.SubtleDehumNonPart_18, 
                                            f.SubtleDehumNonPart_19, f.SubtleDehumNonPart_20)%>%na.omit()
cronbach.alpha(a.SubtleAnimDehumNonPart, CI=T)
#alpha = 0.76 [0.72, 0.79]

#subtle animalistic dehumanization against antipetistas indicator:
main$comp.SubtleAnimDehumNonPart <- (as.numeric(main$f.SubtleDehumNonPart_2)+
                                      as.numeric(main$f.SubtleDehumNonPart_3)+
                                      as.numeric(main$f.SubtleDehumNonPart_7)+
                                      as.numeric(main$f.SubtleDehumNonPart_8)+
                                      as.numeric(main$f.SubtleDehumNonPart_13)+
                                      as.numeric(main$f.SubtleDehumNonPart_15)+
                                      as.numeric(main$f.SubtleDehumNonPart_16)+
                                      as.numeric(main$f.SubtleDehumNonPart_18)+
                                      as.numeric(main$f.SubtleDehumNonPart_19)+
                                      as.numeric(main$f.SubtleDehumNonPart_20))/10
summary(main$comp.SubtleAnimDehumNonPart)

#humanized (-1) to dehumanized (1)
main$s.comp.SubtleAnimDehumNonPart <- rescale(main$comp.SubtleAnimDehumNonPart, 
                                              to = c(1, -1))
summary(main$s.comp.SubtleAnimDehumNonPart)

#higher scores, more dehumanization

```

## Blatant Dehumanization

Following Cassesse (2021), standardizing dependent variable composites.

Turning measures comparable accross different models.

In this code chunk, we standardize the blatant dehumanization variables, 
the subtle de humanization composites, and identity strength composites.

```{r blat_standardize, include=F}

#standardizing to compare effects of partisanship on 
##other dehumanization DVs (as Cassesse (2021) does):
#higher scores, more dehumanization
#Blatant dehumanization:
main$BlatantDehum_1 <- as.numeric(main$BlatantDehum_1)
summary(main$BlatantDehum_1)
main$s.BlatantDehum_1 <- rescale(main$BlatantDehum_1, to = c(1, -1))
summary(main$s.BlatantDehum_1)


main$BlatantDehum_2 <- as.numeric(main$BlatantDehum_2)
summary(main$BlatantDehum_2)
main$s.BlatantDehum_2 <- rescale(main$BlatantDehum_2, to = c(1, -1))
summary(main$s.BlatantDehum_2)


main$BlatantDehum_3 <- as.numeric(main$BlatantDehum_3)
summary(main$BlatantDehum_3)
main$s.BlatantDehum_3 <- rescale(main$BlatantDehum_3, to = c(1, -1))
summary(main$s.BlatantDehum_3)

```



# Social Distance:

```{r socialdistance, include=F}
#Happy AntiPT - petistas respondents
#Happy PT - antipetistas respondents

#higher scores, more distance
#“O quão feliz você ficaria em cada uma 
##das situações descritas abaixo?”
##[Muito infeliz, infeliz, nem feliz nem infeliz, 
##feliz, muito feliz]

## HappyAntiPT_1: 1)	O casamento de um parente 
##com um(a) petista (antipetista)
prop.table(table(main$HappyAntiPT_1))
main$f.HappyAntiPT_1 <- factor(main$HappyAntiPT_1, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))
str(main$f.HappyAntiPT_1)

## HappyAntiPT_2: #2)	Ser escolhido para trabalhar 
##com alguém que apoia (se opõe a) o PT e que 
##gosta de discutir sobre política no trabalho
prop.table(table(main$HappyAntiPT_2))
main$f.HappyAntiPT_2 <- factor(main$HappyAntiPT_2, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))
str(main$f.HappyAntiPT_2)

## HappyAntiPT_3: 3)	Um vizinho colando uma placa 
#com os dizeres “Lula para Presidente” 
#(Bolsonaro para Presidente”) na janela
prop.table(table(main$HappyAntiPT_3))
main$f.HappyAntiPT_3 <- factor(main$HappyAntiPT_3, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))
str(main$f.HappyAntiPT_3)

## HappyAntiPT_4: #4)	Lula (Bolsonaro) recebendo 
#uma condecoração de uma organização 
#internacional pelos trabalhos prestados 
prop.table(table(main$HappyAntiPT_4))
main$f.HappyAntiPT_4 <- factor(main$HappyAntiPT_4, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))
str(main$f.HappyAntiPT_4)

#Alpha Cronbach: internal consistency
a.f.HappyAntiPT <- main %>% select(f.HappyAntiPT_1, f.HappyAntiPT_2, 
                                   f.HappyAntiPT_3, f.HappyAntiPT_4)%>%na.omit()
cronbach.alpha(a.f.HappyAntiPT, CI=T)
#alpha= 0.75 [0.69, 0.8]

#HappyAntiPT composite:
main$comp.HappyAntiPT <- (as.numeric(main$f.HappyAntiPT_1)+
                            as.numeric(main$f.HappyAntiPT_2)+
                            as.numeric(main$f.HappyAntiPT_3)+
                            as.numeric(main$f.HappyAntiPT_4))/4
summary(main$comp.HappyAntiPT)

#standardizing HappyAntiPT composite:
main$s.comp.HappyAntiPT <- rescale(main$comp.HappyAntiPT, to=c(-1,1))
summary(main$s.comp.HappyAntiPT)

## HappyPT_1: 1)	O casamento de um parente 
##com um(a) petista (antipetista)
prop.table(table(main$Q5.1_1))
main$f.HappyPT_1 <- factor(main$Q5.1_1, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))
str(main$f.HappyPT_1)

## HappyPT_2: #2)	Ser escolhido para trabalhar 
##com alguém que apoia (se opõe a) o PT e que 
##gosta de discutir sobre política no trabalho
prop.table(table(main$Q5.1_2))
main$f.HappyPT_2 <- factor(main$Q5.1_2, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))

## HappyPT_3: 3)	Um vizinho colando uma placa 
#com os dizeres “Lula para Presidente” 
#(Bolsonaro para Presidente”) na janela
prop.table(table(main$Q5.1_3))
main$f.HappyPT_3 <- factor(main$Q5.1_3, 
                              level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))

## HappyPT_4: #4)	Lula (Bolsonaro) recebendo 
#uma condecoração de uma organização 
#internacional pelos trabalhos prestados 
prop.table(table(main$Q5.1_4))
main$f.HappyPT_4 <- factor(main$Q5.1_4, 
                               level=c("Muito feliz", "Feliz", 
                                       "Nem feliz nem infeliz", 
                                       "Infeliz", "Muito infeliz"))

#Alpha Cronbach: internal consistency
a.f.HappyPT <- main %>% select(f.HappyPT_1, f.HappyPT_2, f.HappyPT_3, 
                               f.HappyPT_4)%>%na.omit()
cronbach.alpha(a.f.HappyPT, CI=T)
#alpha = 0.85 [0.82, 0.87]


#HappyPT composite:
main$comp.HappyPT <- (as.numeric(main$f.HappyPT_1)+
                            as.numeric(main$f.HappyPT_2)+
                            as.numeric(main$f.HappyPT_3)+
                            as.numeric(main$f.HappyPT_4))/4
summary(main$comp.HappyPT)


#standardizing HappyPT composite:
main$s.comp.HappyPT <- rescale(main$comp.HappyPT, to=c(-1, 1))
summary(main$s.comp.HappyPT)



```

# Moral Distance

```{r moraldistance, include=F}
#higher scores, more distance
#“O quanto Petistas e Antipetistas se diferem 
#quanto as seguintes características?” 
#["Nao Diferem", “Diferem um pouco,” “Diferem muito"]

#Morality_1: empatia pelos outros
prop.table(table(main$Morality_1))
main$f.Morality_1 <- factor(main$Morality_1, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_1)

#Morality_2: justiça
table(main$Morality_2)
main$f.Morality_2 <- factor(main$Morality_2, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_2)

#Morality_3: lealdade/fidelidade
table(main$Morality_3)
main$f.Morality_3 <- factor(main$Morality_3, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_3)

#Morality_4: respeito pela autoridade
table(main$Morality_4)
main$f.Morality_4 <- factor(main$Morality_4, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_4)

#Morality_5:impulsividade
table(main$Morality_5)
main$f.Morality_5 <- factor(main$Morality_5, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_5)

#Morality_6: auto-suficiência
table(main$Morality_6)
main$f.Morality_6 <- factor(main$Morality_6, 
                            levels=c("Não diferem", 
                                     "Diferem um pouco", 
                                     "Diferem muito"))
summary(main$f.Morality_6)

#Alpha Cronbach: internal consistency
a.f.Morality <- main %>% select(f.Morality_1, f.Morality_2, f.Morality_3, 
                                f.Morality_4, f.Morality_5, f.Morality_6)%>%
  na.omit()
cronbach.alpha(a.f.Morality, CI=T)
#alpha= 0.87 [0.85, 0.89]

#creating Morality composite scale: 
main$comp.Morality <- (as.numeric(main$f.Morality_1)+
                         as.numeric(main$f.Morality_2)+
                         as.numeric(main$f.Morality_3)+
                         as.numeric(main$f.Morality_4)+
                         as.numeric(main$f.Morality_5)+
                         as.numeric(main$f.Morality_6))/6
summary(main$comp.Morality)


#standardizing Morality composite:
main$s.comp.Morality <- rescale(main$comp.Morality, to=c(-1,1))
summary(main$s.comp.Morality)




```

# Social Dominance Orientation

```{r sdo, include=F}

#higher scores, more conservative
#SDO16_1 through SDO16_16

#less dominant to more dominant
#1 Discordo totalmente	2 Discordo um pouco	
#3 Não concordo nem discordo	4 Concordo um pouco	
#5 Concordo totalmente
						

# SDO8_1 Provavelmente é bom que alguns grupos 
#estejam em posições superiores e outros em 
#posições inferiores na sociedade.
unique(main$SDO8_1)
table(main$SDO8_1)
main$f.SDO8_1 <- factor(main$SDO8_1, 
                        levels=c("Discordo totalmente", 
                                 "Discordo um pouco", 
                                 "Não concordo nem discordo", 
                                 "Concordo um pouco", 
                                 "Concordo totalmente"))
summary(main$f.SDO8_1)
summary(as.numeric(main$f.SDO8_1))

#SDO8_2 Uma sociedade ideal exige que alguns grupos  
#estejam em posições superiores e outros estejam 
#em posições inferiores na sociedade.
unique(main$SDO8_2)
table(main$SDO8_2)
main$f.SDO8_2 <- factor(main$SDO8_2, 
                        levels=c("Discordo totalmente",
                                 "Discordo um pouco", 
                                 "Não concordo nem discordo", 
                                 "Concordo um pouco", 
                                 "Concordo totalmente"))
summary(main$f.SDO8_2)
summary(as.numeric(main$f.SDO8_2))


#SDO8_3 Nenhum grupo deveria  
#ser dominante na sociedade. (Reverse code)

unique(main$SDO8_3)
table(main$SDO8_3)
main$f.SDO8_3 <- factor(main$SDO8_3, 
                         levels=c("Concordo totalmente", 
                                  "Concordo um pouco", 
                                  "Não concordo nem discordo", 
                                  "Discordo um pouco", 
                                  "Discordo totalmente"))
summary(main$f.SDO8_3)
summary(as.numeric(main$f.SDO8_3))


#SDO8_4 O princípio de que um  grupo deve 
#dominar outro é ruim. (Reverse code)
unique(main$SDO8_4)
table(main$SDO8_4)
main$f.SDO8_4 <- factor(main$SDO8_4, 
                         levels=c("Concordo totalmente", 
                                  "Concordo um pouco", 
                                  "Não concordo nem discordo", 
                                  "Discordo um pouco", 
                                  "Discordo totalmente"))
summary(main$f.SDO8_4)
summary(as.numeric(main$f.SDO8_4))


#SDO8_5 É injusto tentar fazer com que os grupos sejam iguais.
unique(main$SDO8_5)
table(main$SDO8_5)
main$f.SDO8_5 <- factor(main$SDO8_5, 
                          levels=c("Discordo totalmente", 
                                   "Discordo um pouco", 
                                   "Não concordo nem discordo", 
                                   "Concordo um pouco", 
                                   "Concordo totalmente"))
summary(main$f.SDO8_5)
summary(as.numeric(main$f.SDO8_5))

#SDO8_6 Nosso objetivo principal não 
#deveria ser a igualdade entre os grupos.

unique(main$SDO8_6)
table(main$SDO8_6)
main$f.SDO8_6 <- factor(main$SDO8_6,
                          levels=c("Discordo totalmente",
                                   "Discordo um pouco",
                                   "Não concordo nem discordo",
                                   "Concordo um pouco",
                                   "Concordo totalmente"))
summary(main$f.SDO8_6)
summary(as.numeric(main$f.SDO8_6))


#SDO8_7 Não importa quanto esforço seja necessário,  
#nós devemos nos esforçar para assegurar que todos 
#os grupos tenham as mesmas chances na vida. (Reverse code)
unique(main$SDO8_7)
table(main$SDO8_7)
main$f.SDO8_7 <- factor(main$SDO8_7, 
                                      levels=c("Concordo totalmente", 
                                               "Concordo um pouco", 
                                               "Não concordo nem discordo", 
                                               "Discordo um pouco", 
                                               "Discordo totalmente"))
summary(main$f.SDO8_7)
summary(as.numeric(main$f.SDO8_7))

#SDO8_8 Nosso ideal deveria ser a igualdade 
#entre grupos. (Reverse code)
unique(main$SDO8_8)
table(main$SDO8_8)
main$f.SDO8_8 <- factor(main$SDO8_8, 
                                      levels=c("Concordo totalmente", 
                                               "Concordo um pouco", 
                                               "Não concordo nem discordo", 
                                               "Discordo um pouco", 
                                               "Discordo totalmente"))
summary(main$f.SDO8_8)
summary(as.numeric(main$f.SDO8_8))


#Alpha Cronbach: internal consistency
a.f.SDO8 <- main %>% select(f.SDO8_1, f.SDO8_2, f.SDO8_3, f.SDO8_4, 
                             f.SDO8_5, f.SDO8_6, f.SDO8_7, f.SDO8_8)%>%
  na.omit()
cronbach.alpha(a.f.SDO8, CI=T)
#alpha = 0.64 [0.61, 0.67]

#create composite for social dominance orientation:
main$comp.SDO <- (as.numeric(main$f.SDO8_1)+
                    as.numeric(main$f.SDO8_2)+
                    as.numeric(main$f.SDO8_3)+
                    as.numeric(main$f.SDO8_4)+
                    as.numeric(main$f.SDO8_5)+
                    as.numeric(main$f.SDO8_6)+
                    as.numeric(main$f.SDO8_7)+
                    as.numeric(main$f.SDO8_8))/8

summary(main$comp.SDO)
#standardizing composite for consistency and 
#comparability with other measures:
main$s.comp.SDO <- rescale(main$comp.SDO, to=c(-1,1))
summary(main$s.comp.SDO)
str(main$s.comp.SDO)

```

# Coalesce targeted IVs:

```{r coalesce_ivs, include=F}

main$id_strength <- coalesce(main$s.comp.Antipetismo, main$s.comp.Petismo)

main$s.comp.Happy <- coalesce(main$s.comp.HappyAntiPT, main$s.comp.HappyPT)

main$partisanship <- "NA"
main$partisanship[main$Petistas==1] <- "Petistas"
main$partisanship[main$Antipetistas==1] <- "Antipetistas"
main$partisanship[main$NonPartisans==1] <- "NonPartisans"
prop.table(table(main$partisanship))
#perhaps run for clarification of NAs:
#main$partisanship[main$partisanship=="NA"] <- "otherpartisan(pos&neg)"


main$voting1 <- "NA" #NA = voted for Lula, Bolsonaro or did not answer the quesetion
main$voting1[main$Lulistas==1] <- "Lulistas"
main$voting1[main$Bolsonaristas==1] <- "Bolsonaristas"
main$voting1[main$NonPartisans2==1] <- "NonPartisans2"
main$voting1[main$Antipetistas==1 & main$Q80=="Lula"] <- "AntiPT_Lula"
main$voting1[main$Petistas==1 & main$Q80=="Jair Bolsonaro"] <- "PT_Bolso"


prop.table(table(main$voting))

past_new_categories <- prop.table(table(main$partisanship, main$voting))
print(past_new_categories)


#New categories:
main$voting <- NA #NA = voted for Lula, Bolsonaro or did not answer the quesetion
main$voting[main$Lulistas==1] <- "Lulistas"
main$voting[main$Bolsonaristas==1] <- "Bolsonaristas"
main$voting[main$NonPartisans2==1] <- "NonPartisans2"
main$voting[main$Antipetistas==1] <- "Antipetistas"
main$voting[main$Petistas==1] <- "Petistas"



#s.comp.Morality means:
main %>%
    group_by(partisanship) %>%
    dplyr::summarize(Mean = mean(s.comp.Morality, na.rm=TRUE))
#petistas mean "social distance from antipetistas"
#antipetistas mean "social distance from petistas"
main %>% group_by(partisanship) %>% dplyr::summarize(mean=mean(s.comp.Happy, 
                                                               na.rm=T))

main %>% group_by(partisanship) %>% dplyr::summarize(mean=mean(s.comp.HappyAntiPT, 
                                                               na.rm=T))

main %>% group_by(partisanship) %>% dplyr::summarize(mean=mean(s.comp.HappyPT, 
                                                               na.rm=T))




main %>% group_by(partisanship, voting) %>% dplyr::summarize(mean=mean(s.BlatantDehum_2, 
                                                               na.rm=T))

#s.comp.SDO means:
main %>%
    group_by(partisanship) %>%
    dplyr::summarize(Mean = mean(s.comp.SDO, na.rm=TRUE), sd=sd(s.comp.SDO, na.rm=TRUE))

```


# Plots and Regressions in the article

## Kitchen sink models

Dataset = "main" 

Includes dehumanization variables as DVs, correlates as IVs, 
controls, and Threat variable

### Blatant dehumanization

```{r blatant_kitchensink, include=T}

#subset "main" 
#includes dehumanization variables as DVs, correlates as IVs, controls, and 
#Threat variable

#blatant dehumanization against petistas:
#id_strength can't be inserted as IV with party group dummies
ksblat1 <- lm(s.BlatantDehum_1~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat1)


#blatant dehumanization against antipetistas:
ksblat2 <- lm(s.BlatantDehum_2~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat2)

#blatant dehumanization against nonpartisans
ksblat3 <- lm(s.BlatantDehum_3~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat3)


#plot:
t_ksblat1 <-
    broom::tidy(ksblat1) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Petistas") 
t_ksblat2 <-
    broom::tidy(ksblat2) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Antipetistas")
t_ksblat3 <-
    broom::tidy(ksblat3) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Nonpartisans")

ksblat <- rbind(t_ksblat1, t_ksblat2, t_ksblat3)%>% arrange(desc(model))

ksblat$model <- factor(ksblat$model, 
levels = c("Antipetistas", "Nonpartisans","Petistas"), 
labels = c("Antipetistas", "Nonpartisans","Petistas"))


plot_ksblat <- dwplot(ksblat,
                      vline = geom_vline(
           xintercept = 0,
           colour = "red",
           linetype = 2
           ),
       vars_order = c("Antipetistas", "Bolsonaristas", "NonPartisans2", "Lulistas", "Petistas"),
       model_order = c("Antipetistas", "Nonpartisans","Petistas")
       ) + xlab("Dehumanization") + xlim(-1, 1) + ylab("")+  
 theme_bw(base_size=8) + 
   scale_colour_grey(start=0.2, end=0.8,
        name = "Targeted Groups",
        #guide = guide_legend(reverse = TRUE),
        breaks = c("Petistas", "Nonpartisans", "Antipetistas"))+
  guides(colour = guide_legend(reverse=F))+
  scale_y_discrete(labels=c("Petistas", "Lulistas", "Nonpartisans", "Bolsonaristas", "Antipetistas"))+
  #ggtitle ("Figure 2A.  Blatant")+
  coord_flip()


plot_ksblat
```


### +pl+pureAntipetistas Blatant dehumanization

```{r blatant_kitchensink, include=T}

#subset "main" 
#includes dehumanization variables as DVs, correlates as IVs, controls, and 
#Threat variable

#blatant dehumanization against petistas:
#id_strength can't be inserted as IV with party group dummies
pksblat1 <- lm(s.BlatantDehum_1~Petistas+plAntipetistas+pureAntipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(pksblat1)


#blatant dehumanization against antipetistas:
pksblat2 <- lm(s.BlatantDehum_2~Petistas+plAntipetistas+pureAntipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(pksblat2)

#blatant dehumanization against nonpartisans
pksblat3 <- lm(s.BlatantDehum_3~Petistas+plAntipetistas+pureAntipetistas+Lulistas+Bolsonaristas+NonPartisans2+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(pksblat3)


#plot:
t_pksblat1 <-
    broom::tidy(pksblat1) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Petistas") 
t_pksblat2 <-
    broom::tidy(pksblat2) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Antipetistas")
t_pksblat3 <-
    broom::tidy(pksblat3) %>% filter(term !="(Intercept)")%>% 
  filter(term !="s.comp.Happy")%>% filter(term !="s.comp.Morality") %>% 
  filter(term !="s.comp.SDO") %>% filter(!grepl('HHIncome*', term))%>% 
  filter(!grepl('Educ*', term))%>% filter(!grepl('Race*', term))%>% 
  filter(!grepl('Region*', term))%>% filter(!grepl('Age*', term))%>% 
  filter(!grepl('Gender*', term))%>% filter(!grepl('Threat*', term))%>% 
  mutate(model = "Nonpartisans")

pksblat <- rbind(t_pksblat1, t_pksblat2, t_pksblat3)%>% arrange(desc(model))

pksblat$model <- factor(pksblat$model, 
levels = c("Antipetistas", "Nonpartisans","Petistas"), 
labels = c("Antipetistas", "Nonpartisans","Petistas"))


plot_pksblat <- dwplot(pksblat,
                      vline = geom_vline(
           xintercept = 0,
           colour = "red",
           linetype = 2
           ),
       vars_order = c("plAntipetistas","pureAntipetistas", "Bolsonaristas", "NonPartisans2", "Lulistas", "Petistas"),
       model_order = c("Antipetistas", "Nonpartisans","Petistas")
       ) + xlab("Dehumanization") + xlim(-1, 1) + ylab("")+  
 theme_bw(base_size=8) + 
   scale_colour_grey(start=0.2, end=0.8,
        name = "Targeted Groups",
        #guide = guide_legend(reverse = TRUE),
        breaks = c("Petistas", "Nonpartisans", "Antipetistas"))+
  guides(colour = guide_legend(reverse=F))+
  scale_y_discrete(labels=c("Petistas", "Lulistas", "Nonpartisans", "Bolsonaristas", "Pure Antipetistas", "plAntipetistas"))+
  #ggtitle ("Figure 2A.  Blatant")+
  coord_flip()


plot_pksblat
```

## New Partisan Intensity and Dehumanization
```{r kitchensink_newidstrength, include=T}

#Evaluation by petistas

ksblat1_pt <- lm(s.BlatantDehum_1~s.comp.Petismo+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat1_pt)

ksblat2_pt <- lm(s.BlatantDehum_2~s.comp.Petismo+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat2_pt)

pred_ksblat1_pt <- ggpredict(ksblat1_pt, terms = "s.comp.Petismo")
pred_ksblat1_pt$model <- NA
pred_ksblat1_pt$model[is.na(pred_ksblat1_pt$model)] <- "Petistas"
pred_ksblat2_pt <- ggpredict(ksblat2_pt, terms = "s.comp.Petismo")
pred_ksblat2_pt$model <- NA
pred_ksblat2_pt$model[is.na(pred_ksblat2_pt$model)] <- "Antipetistas"

pred_ksblat_pt <- rbind(pred_ksblat1_pt, pred_ksblat2_pt)%>% arrange(desc(model))

plot_pred_ksblat_pt<- ggplot(pred_ksblat_pt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Id strength - Petistas")+ylab("Dehumanization") 

plot_pred_ksblat_pt


#Evaluations by antipetistas


ksblat1_antipt <- lm(s.BlatantDehum_1~s.comp.Antipetismo+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat1_antipt)

ksblat2_antipt <- lm(s.BlatantDehum_2~s.comp.Antipetismo+
                s.comp.Happy+s.comp.Morality+s.comp.SDO+Age+Region+Race+Gender+
                Educ+HHIncome+Threat, main)
summary(ksblat2_antipt)

pred_ksblat1_antipt <- ggpredict(ksblat1_antipt, terms = "s.comp.Antipetismo")
pred_ksblat1_antipt$model <- NA
pred_ksblat1_antipt$model[is.na(pred_ksblat1_antipt$model)] <- "Petistas"
pred_ksblat2_antipt <- ggpredict(ksblat2_antipt, terms = "s.comp.Antipetismo")
pred_ksblat2_antipt$model <- NA
pred_ksblat2_antipt$model[is.na(pred_ksblat2_antipt$model)] <- "Antipetistas"

pred_ksblat_antipt <- rbind(pred_ksblat1_antipt, pred_ksblat2_antipt)%>% arrange(desc(model))

plot_pred_ksblat_antipt<- ggplot(pred_ksblat_antipt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Id strength - Antipetistas")+ylab("Dehumanization") 

plot_pred_ksblat_antipt

```

## Partisan Threats

```{r exp1, include=F}
table(main$Threat)
prop.table(table(main$Threat))

table(main$Threat, main$partisanship)
prop.table(table(main$Threat, main$GroupName))



control <- subset(main, Threat=="Control")
#458 observations
#distribution in the main indenpendent variables:
table(control$Petistas) #97
table(control$Antipetistas) #204
table(control$NonPartisans2) #46
table(control$Lulistas)#62
table(control$Bolsonaristas)#36 #missing 6 participants
#reporting the power of our analysis with the number of responses we have:
#we need at least 50 in each group in the control condition

# Threat about antipetistas (antipetistas were not exposed to this condition)
Threat_APT <- subset(main, Threat=="Threat_APT")
#266 observations
#distribution in the main indenpendent variables:
table(Threat_APT$Petistas) #99
table(Threat_APT$NonPartisans2) #42 #missing 2 participants
table(Threat_APT$Lulistas)#68
table(Threat_APT$Bolsonaristas)#46
pwr::pwr.anova.test(k=4, power=.8, sig.level=0.05, f=0.25)
#we need at least 44 in petistas and non partisans in this threat condition

# Threat about petistas (petistas were not exposed to this condition)
Threat_PT <- subset(main, Threat=="Threat_PT")
#355 observations
#distribution in the main indenpendent variables:
table(Threat_PT$Antipetistas) #199
table(Threat_PT$NonPartisans2) #45 #a litlle shorter than what we need
table(Threat_PT$Lulistas)#69
table(Threat_PT$Bolsonaristas)#21


```

```{r exp_cassesse, include=T}

#Control
control_blat1 <- lm(s.BlatantDehum_1~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+                  s.comp.Happy+s.comp.Morality+ s.comp.SDO+Age+
Region+Gender+Race+Educ+HHIncome, control)
summary(control_blat1)


control_blat2 <- lm(s.BlatantDehum_2~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+                  s.comp.Happy+s.comp.Morality+ s.comp.SDO+Age+
Region+Gender+Race+Educ+HHIncome, control)
summary(control_blat2)


control_blat3 <- lm(s.BlatantDehum_3~Petistas+Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+                  s.comp.Happy+s.comp.Morality+ s.comp.SDO+Age+
Region+Gender+Race+Educ+HHIncome, control)
summary(control_blat3)


t_control_blat1 <- tidy(control_blat1)%>%mutate(model="Petistas")
t_control_blat2 <- tidy(control_blat2)%>%mutate(model="Antipetistas")
t_control_blat3 <- tidy(control_blat3)%>%mutate(model="Nonpartisans")

t_control_blat <- rbind(t_control_blat1, t_control_blat2, t_control_blat3)

control <- dwplot(t_control_blat,
                      vline = geom_vline(
           xintercept = 0,
           colour = "red",
           linetype = 2
           ),
       vars_order = c("Antipetistas","Bolsonaristas", "NonPartisans2","Lulistas",  "Petistas"),
       model_order = c("Antipetistas", "Nonpartisans","Petistas")
       ) + xlab("Dehumanization") + xlim(-1, 1) + ylab("")+  
 theme_bw(base_size=8) + 
   scale_colour_grey(start=0.2, end=0.8,
        name = "Targeted Groups",
        #guide = guide_legend(reverse = TRUE),
        breaks = c("Petistas", "Nonpartisans", "Antipetistas"))+ 
  guides(colour = guide_legend(reverse=F))+
  ggtitle ("Figure 5A.  No Threat")+
  scale_y_discrete(labels=c("Petistas", "Lulistas", "Nonpartisans", "Bolsonaristas", "Antipetistas"))+ coord_flip()

control


# Threat about antipetistas (antipetistas were not exposed to this condition)
Threat_APT_blat1 <- lm(s.BlatantDehum_1~Petistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+Gender+
                  Race+Educ+HHIncome, Threat_APT)
summary(Threat_APT_blat1)


Threat_APT_blat2 <- lm(s.BlatantDehum_2~Petistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+Gender+
                  Race+Educ+HHIncome, Threat_APT)
summary(Threat_APT_blat2)


Threat_APT_blat3 <- lm(s.BlatantDehum_3~Petistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+Gender+
                  Race+Educ+HHIncome, Threat_APT)
summary(Threat_APT_blat3)


t_Threat_APT_blat1 <- tidy(Threat_APT_blat1)%>%mutate(model="Petistas")
t_Threat_APT_blat2 <-tidy(Threat_APT_blat2)%>%mutate(model="Antipetistas")
t_Threat_APT_blat3 <- tidy(Threat_APT_blat3)%>%mutate(model="Nonpartisans")

t_Threat_APT <- rbind(t_Threat_APT_blat1, t_Threat_APT_blat2, t_Threat_APT_blat3)

ltb <- dwplot(t_Threat_APT,
                      vline = geom_vline(
           xintercept = 0,
           colour = "red",
           linetype = 2
           ),
       vars_order = c("NonPartisans2", "Lulistas", "Petistas"),
       model_order = c("Antipetistas", "Nonpartisans","Petistas")
       ) + xlab("Dehumanization") + xlim(-1, 1) + ylab("")+  
 theme_bw(base_size=8) + 
   scale_colour_grey(start=0.2, end=0.8,
        name = "Targeted Groups",
        #guide = guide_legend(reverse = TRUE),
        breaks = c("Petistas", "Nonpartisans", "Antipetistas"))+ 
  guides(colour = guide_legend(reverse=F))+
  ggtitle ("Figure 5B. Threat about Antipetistas")+
  scale_y_discrete(labels=c("Petistas", "Lulistas", "Nonpartisans"))+coord_flip()

ltb


#Threat about petistas

Threat_PT_blat1 <- lm(s.BlatantDehum_1~Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+
                  Gender+Race+Educ+HHIncome, Threat_PT)
summary(Threat_PT_blat1)


Threat_PT_blat2 <- lm(s.BlatantDehum_2~Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+
                  Gender+Race+Educ+HHIncome, Threat_PT)
summary(Threat_PT_blat2)


Threat_PT_blat3 <- lm(s.BlatantDehum_3~Antipetistas+Lulistas+Bolsonaristas+NonPartisans2+s.comp.Happy+
                  s.comp.Morality+
                          s.comp.SDO+Age+Region+
                  Gender+Race+Educ+HHIncome, Threat_PT)
summary(Threat_PT_blat3)


t_Threat_PT_blat1 <- tidy(Threat_PT_blat1)%>%mutate(model="Petistas")
t_Threat_PT_blat2 <- tidy(Threat_PT_blat2)%>%mutate(model="Antipetistas")
t_Threat_PT_blat3 <- tidy(Threat_PT_blat3)%>%mutate(model="Nonpartisans")

t_Threat_PT_blat <- rbind(t_Threat_PT_blat1, t_Threat_PT_blat2, t_Threat_PT_blat3)

ltl <- dwplot(t_Threat_PT_blat,
                      vline = geom_vline(
           xintercept = 0,
           colour = "red",
           linetype = 2),
       vars_order = c("Antipetistas","Bolsonaristas", "NonPartisans2"),
       model_order = c("Antipetistas", "Nonpartisans","Petistas")
       ) + xlab("Dehumanization") + xlim(-1, 1) + ylab("")+  
 theme_bw(base_size=8) + 
   scale_colour_grey(start=0.2, end=0.8,
        name = "Targeted Groups",
        #guide = guide_legend(reverse = TRUE),
        breaks = c("Petistas", "Nonpartisans", "Antipetistas"))+ 
  guides(colour = guide_legend(reverse=F))+
  ggtitle ("Figure 5C.  Threat about Petistas")+scale_y_discrete(labels=c("Nonpartisans", "Bolsonaristas", "Antipetistas"))+coord_flip()

ltl

experiment <- ggarrange(control,
        ggarrange(ltb, ltl, ncol = 2, align = "h",widths = c(1.5,1.5), legend="none"), 
      common.legend = TRUE, 
      legend = "bottom",
      nrow = 2, 
      heights = c(1.5, 1.5)
      ) 

experiment

#in this sample, petistas dehumanized antipetistas post-treatment.
```

## Correlates with Dehumanization

### Old SDO 
```{r sdo1, include=F}
#emmeans package to evaluate interactions (UCLA - r stats resources)

# Social Dominance Orientation------------------------------------------------

# DS 1: if you haven't, please create a 2x2 or a xtab where you separate petistas and antipetstas into high and low values on SDO (at the median and then compute the avg dehumanization score for the ppl in each of those 4 cells. (I think this is what I want to see)

# DS 2: Thinking out loud here: I'm really struck by the fact that both petistas and antipetistas score "negatively" on SDO, ie "everybody" wants a more equal society. I don't want the fact to get lost that antipetistas score much "higher" on SDO than petistas, and please confirm that that is true - that antipetistas are statistically significantly "higher" on SDO than petistas on average. Given that, and given that antipetistas dehumanize so extensively, perhaps it's not surprising that SDO doesn't "increase" dehumanization for antipetistas?
#Also, one way that SDO would not be correlated with dehumanization for antipetistas is if variance on SDO is low AND variance on dehumanization of petistas is also very low. Does this make sense, and to what extent does it hold up in the data?



#checking collinearity
test4 <- lm(s.comp.SDO~partisanship, main)
test4 <- lm.beta(test4)
summary(test4)

test6 <- lm(s.comp.SDO~Threat, main)
test6 <- lm.beta(test6)
summary(test6)

test7 <- lm(s.comp.SDO~HHIncome, main)
test7 <- lm.beta(test7)
summary(test7)

test8 <- lm(s.comp.SDO~Educ, main)
test8 <- lm.beta(test8)
summary(test8)

test9 <- lm(s.comp.SDO~Race, main)
test9 <- lm.beta(test9)
summary(test9)

test10 <- lm(s.comp.SDO~Gender, main)
test10 <- lm.beta(test10)
summary(test10)# women are lower on SDO

test13 <- lm(s.comp.SDO~Age, main)
test13 <- lm.beta(test13)
summary(test13)
#only income is not correlated with SDO.

test14 <- lm(s.comp.SDO~Region, main)
test14 <- lm.beta(test14)
summary(test14)


summary(main$s.comp.SDO) 

sd_mean_sdo <- main %>% group_by(voting) %>% 
  dplyr::summarize(mean=mean(s.comp.SDO, na.rm=T), std.dev=sd(s.comp.SDO, na.rm=T))


mean(main$s.comp.SDO, na.rm=T)
#sample mean = -.32
sd(main$s.comp.SDO, na.rm=T)
#standard deviation = 0.43



#proportion of petistas and antipetistas that are 1 SD greater than the overall sample mean
-.32+.43
highsdo <- subset(main, s.comp.SDO>= 0.11)
highsdo_meanparty <- highsdo %>%
    group_by(voting) %>%
    dplyr::summarize(high.Mean = mean(s.comp.SDO, na.rm=TRUE))

prop.table(table(highsdo$voting)) 
#NonPartisans 2 - 0.0769
#Antipetistas - 0.628
#Bolsonaristas - 0.083
#Lulistas - 0.12
#Petistas -  0.09

#what's the proportion of partisans in each SDO level group?
main$sdolevels <- NA
main$sdolevels[main$s.comp.SDO> 0.11] <- "highSDO"
-.32-.43 
main$sdolevels[main$s.comp.SDO< -0.75] <- "lowSDO"
main$sdolevels[main$s.comp.SDO<= 0.11 & main$s.comp.SDO>= -0.75] <- "middleSDO"
table(main$sdolevels)
table(main$voting)

antipt <- subset(main, voting=="Antipetistas")
prop.table(table(antipt$sdolevel)) #27% of antipetistas are in high sdo levels (more than 1 standard deviation  above the mean); 13# in low scores (less than 1 standard deviation below the mean); 59% in average levels 

pt <- subset(main, voting=="Petistas")
prop.table(table(pt$sdolevels)) #8% of petistas are in high sdo levels; 24% in low sdo levels; and 67% in average levels

lulistas <- subset(main, voting=="Lulistas")
prop.table(table(lulistas$sdolevels))#14% od lulistas are in high sdo levels; 19% in low sdo levels; and 67% in average levels

bolsonaristas <- subset(main, voting=="Bolsonaristas")
prop.table(table(bolsonaristas$sdolevels))# 19% of bolsonaristas are in high sdo levels; 9% in low sdo levels; and 72% in average levels

nonpartisans <- subset(main, voting=="NonPartisans2")
prop.table(table(nonpartisans$sdolevels)) # 11% of nonpartisans are in high sdo levels; 15% in low sdo levels; and 73% in average levels

#subset main data into observations high on SDO - high=above or equal the median
highsdo <- subset(main, s.comp.SDO>=median(main$s.comp.SDO, na.rm=T))
highsdo_meanparty <- highsdo %>%
    group_by(voting) %>%
    dplyr::summarize(high.Mean = mean(s.comp.SDO, na.rm=TRUE))

#subset main data into observations low on SDO - low= below the median
lowsdo <- subset(main, s.comp.SDO<median(main$s.comp.SDO, na.rm=T))
lowsdo_meanparty <- lowsdo %>%
    group_by(voting) %>%
    dplyr::summarize(low.Mean = mean(s.comp.SDO, na.rm=TRUE))

#table mean of sdo at low and high levels of sdo by partisanship:
sdo_meanparty <- merge(highsdo_meanparty, lowsdo_meanparty, by="voting")

#pairwise t-tests of  s.comp.SDO by partisanship:
# where y is numeric and x is a binary factor
library(rstatix)
pwc <- main %>%
  rstatix::pairwise_t_test(s.comp.SDO ~ partisanship, p.adjust.method = "bonferroni")
pwc


#number of observations by partisanship:
prop.table(table(highsdo$voting)) #number of antipetistas is 7 times higher than of 
# petistas
prop.table(table(lowsdo$voting)) #number of petistas (300) and antipetistas (485) is 
# more evenly distributed

# means of blatant dehumanization at different levels of s.comp.sdo by partisanship
mean_blatant_highsdo<- highsdo %>%
    group_by(partisanship) %>%
    dplyr::summarize(highSDO_Blatant.ag.PT.mean = mean(s.BlatantDehum_1, na.rm=TRUE), highSDO_Blatant.ag.AntiPT.mean = mean(s.BlatantDehum_2, na.rm=TRUE))%>%filter(partisanship!="NonPartisans")
mean_blatant_lowsdo <- lowsdo %>%
    group_by(partisanship) %>%
    dplyr::summarize(lowSDO_Blatant.ag.PT.mean = mean(s.BlatantDehum_1, na.rm=TRUE), lowSDO_Blatant.ag.AntiPT.mean = mean(s.BlatantDehum_2, na.rm=TRUE))%>%filter(partisanship!="NonPartisans")
#table of dehumanization at high and low levels of s.comp.SDO by partisanship
mean_blatant_sdo <- merge(mean_blatant_highsdo,mean_blatant_lowsdo, by="partisanship")

# models ---------------------------------------------------------------------

 ### Change reference level
main$voting <- as.factor(main$voting)
main$voting <- relevel(main$voting, "NonPartisans2")
correlates <- lm(s.BlatantDehum_1~s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(correlates)
emm_options(rg.limit = 2000000) #emtrends needs more space to run
emtrends(correlates, ~voting, var="s.comp.SDO")
emtrends(correlates, pairwise ~voting, var="s.comp.SDO")

## Blatant Dehumanization against AntiPT
correlates1 <- lm(s.BlatantDehum_2~s.comp.Happy*voting+
                         s.comp.Morality*voting+s.comp.SDO*voting+
                         Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(correlates1)
emtrends(correlates1, ~voting, var="s.comp.SDO")
emtrends(correlates1, pairwise ~ voting, var="s.comp.SDO")

#plotting:
(mylist <- list(s.comp.SDO=seq(-1,1,by=0.25), voting=c("Lulistas", "Petistas")))
sdoPT<- emmip(correlates, voting ~s.comp.SDO, at=mylist,CIs=TRUE, plotit=F) 
sdoPT$voting <- factor(sdoPT$voting)
levels(sdoPT$voting) <-c("Lulistas", "Petistas")
p.sdoPT <- ggplot(data=sdoPT, aes(x=s.comp.SDO, y=yvar, 
                                       color=voting)) + geom_line()
p1.sdoPT  <- p.sdoPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  ylab("Dehumanization of Petistas")+
  xlab("Social Dominance Orientation")+ylim(-1,1)
p1.sdoPT

(mylist <- list(s.comp.SDO=seq(-1,1,by=0.25), voting=c("Bolsonaristas", "Antipetistas")))
sdoPT<- emmip(correlates, voting ~s.comp.SDO, at=mylist,CIs=TRUE, plotit=F) 
sdoPT$voting <- factor(sdoPT$voting)
levels(sdoPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.sdoPT <- ggplot(data=sdoPT, aes(x=s.comp.SDO, y=yvar, 
                                       color=voting)) + geom_line()
p2.sdoPT  <- p.sdoPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  ylab("Dehumanization of Petistas")+
  xlab("Social Dominance Orientation")+ylim(-1,1)
p2.sdoPT


(mylist <- list(s.comp.SDO=seq(-1,1,by=0.25), voting=c("Lulistas", "Petistas")))
sdoAntiPT<- emmip(correlates1, voting ~s.comp.SDO, at=mylist,CIs=TRUE, plotit=F) 
sdoAntiPT$voting <- factor(sdoAntiPT$voting)
levels(sdoAntiPT$voting) <-c("Lulistas", "Petistas")
p.sdoAntiPT <- ggplot(data=sdoAntiPT, aes(x=s.comp.SDO, y=yvar, 
                                       color=voting)) + geom_line()
p1.sdoAntiPT  <- p.sdoAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  ylab("Dehumanization of Antipetistas")+
  xlab("Social Dominance Orientation")+ylim(-1.4,1)
p1.sdoAntiPT


(mylist <- list(s.comp.SDO=seq(-1,1,by=0.25), voting=c("Bolsonaristas", "Antipetistas")))
sdoAntiPT<- emmip(correlates1, voting ~s.comp.SDO, at=mylist,CIs=TRUE, plotit=F) 
sdoAntiPT$voting <- factor(sdoAntiPT$voting)
levels(sdoAntiPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.sdoAntiPT <- ggplot(data=sdoAntiPT, aes(x=s.comp.SDO, y=yvar, 
                                       color=voting)) + geom_line()
p2.sdoAntiPT  <- p.sdoAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  ylab("Dehumanization of Antipetistas")+
  xlab("Social Dominance Orientation")+ylim(-1.4,1)
p2.sdoAntiPT



sdo <- ggarrange(p1.sdoPT, p2.sdoPT, p1.sdoAntiPT, p2.sdoAntiPT, ncol = 2, align = "h", widths = c(1.5,1.5),
      common.legend = F, 
      legend = "bottom",
      nrow = 2, 
      heights = c(5, 5)
      ) 
sdo

```

### New SDO

```{r newsdo, include=T}
sdo1pt <- lm(s.BlatantDehum_1~s.comp.HappyAntiPT*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdo1pt)

sdo2pt <- lm(s.BlatantDehum_2~s.comp.HappyAntiPT*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdo2pt)

pred_sdo1pt <- ggpredict(sdo1pt, terms = c("s.comp.SDO", "Petistas"))
pred_sdo1pt$model <- NA
pred_sdo1pt$model[is.na(pred_sdo1pt$model)] <- "Petistas"
pred_sdo2pt <- ggpredict(sdo2pt, terms = c("s.comp.SDO", "Petistas"))
pred_sdo2pt$model <- NA
pred_sdo2pt$model[is.na(pred_sdo2pt$model)] <- "Antipetistas"

pred_sdopt <- rbind(pred_sdo1pt, pred_sdo2pt)%>% arrange(desc(model))
pred_sdopt <- subset(pred_sdopt, group==1)


plot_pred_sdopt<- ggplot(pred_sdopt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1,1.3)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Social Dominance Orientation")+ylab("Dehumanization")+ggtitle("SDO - Evaluation by Petistas")  

plot_pred_sdopt #Evaluations by petistas

#Evaluations by antipetistas

sdo1antipt <- lm(s.BlatantDehum_1~s.comp.HappyPT*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdo1antipt)

sdo2antipt <- lm(s.BlatantDehum_2~s.comp.HappyPT*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdo2antipt)

pred_sdo1antipt <- ggpredict(sdo1antipt, terms = c("s.comp.SDO", "Antipetistas"))
pred_sdo1antipt$model <- NA
pred_sdo1antipt$model[is.na(pred_sdo1antipt$model)] <- "Petistas"
pred_sdo2antipt <- ggpredict(sdo2antipt, terms = c("s.comp.SDO", "Antipetistas"))
pred_sdo2antipt$model <- NA
pred_sdo2antipt$model[is.na(pred_sdo2antipt$model)] <- "Antipetistas"

pred_sdoantipt <- rbind(pred_sdo1antipt, pred_sdo2antipt)%>% arrange(desc(model))
pred_sdoantipt <- subset(pred_sdoantipt, group==1)


plot_pred_sdoantipt<- ggplot(pred_sdoantipt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1.3,1)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Social Dominance Orientation")+ylab("Dehumanization")+ggtitle("SDO - Evaluation by Antipetistas") 
 
plot_pred_sdoantipt

#Putting them together: 

socialdominance<- ggarrange(plot_pred_sdopt, plot_pred_sdoantipt,
  common.legend = T, legend = "bottom", nrow=1, ncol=2, 
      heights = c(5, 5)
  )
socialdominance

#SDO and partisan intensity:

sdoPTismo <- lm(s.comp.SDO~s.comp.Petismo+s.comp.Happy+s.comp.Morality+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdoPTismo)

sdoAntiPTismo <- lm(s.comp.SDO~ s.comp.Antipetismo+s.comp.Happy+s.comp.Morality+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sdoAntiPTismo)


#ploting:


pred_sdo1ptismo <- ggpredict(sdoPTismo, terms = c("s.comp.Petismo"))
pred_sdo1ptismo$model <- NA
pred_sdo1ptismo$model[is.na(pred_sdo1ptismo$model)] <- "Petistas"
pred_sdo1AntiPTismo <- ggpredict(sdoAntiPTismo, terms = c("s.comp.Antipetismo"))
pred_sdo1AntiPTismo$model <- NA
pred_sdo1AntiPTismo$model[is.na(pred_sdo1AntiPTismo$model)] <- "Antipetistas"

pred_sdointensity <- rbind(pred_sdo1ptismo, pred_sdo1AntiPTismo)%>% arrange(desc(model))


plot_pred_sdointensity<- ggplot(pred_sdointensity, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1,1.3)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Partisans")+
  xlab("Partisan Intensity")+ylab("Social Dominance Orientation")+ggtitle("SDO - Partisan Intensity")  

plot_pred_sdointensity

```


### New Social distance
```{r newsocialdistance, include=T}

mean(main$s.comp.Happy, na.rm=T)

main %>%
    group_by(voting) %>%
    dplyr::summarize(Mean = mean(s.comp.Happy, na.rm=TRUE))

#pairwise t-tests of  s.comp.SDO by partisanship:
# where y is numeric and x is a binary factor
pwc <- main %>%
  rstatix::pairwise_t_test(s.comp.Happy ~ voting, p.adjust.method = "bonferroni")
pwc


#Evaluation by petistas

sd1pt <- lm(s.BlatantDehum_1~s.comp.HappyAntiPT*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sd1pt)

sd2pt <- lm(s.BlatantDehum_2~s.comp.HappyAntiPT*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sd2pt)

pred_sd1pt <- ggpredict(sd1pt, terms = c("s.comp.HappyAntiPT", "Petistas"))
pred_sd1pt$model <- NA
pred_sd1pt$model[is.na(pred_sd1pt$model)] <- "Petistas"
pred_sd2pt <- ggpredict(sd2pt, terms = c("s.comp.HappyAntiPT", "Petistas"))
pred_sd2pt$model <- NA
pred_sd2pt$model[is.na(pred_sd2pt$model)] <- "Antipetistas"

pred_sdpt <- rbind(pred_sd1pt, pred_sd2pt)%>% arrange(desc(model))
pred_sdpt <- subset(pred_sdpt, group==1)


plot_pred_sdpt<- ggplot(pred_sdpt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1,1.3)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Social Distance")+ylab("Dehumanization")+ggtitle("Social Distance - Evaluation by Petistas")  

plot_pred_sdpt #Evaluations by petistas

#Evaluations by antipetistas

sd1antipt <- lm(s.BlatantDehum_1~s.comp.HappyPT*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sd1antipt)

sd2antipt <- lm(s.BlatantDehum_2~s.comp.HappyPT*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(sd2antipt)

pred_sd1antipt <- ggpredict(sd1antipt, terms = c("s.comp.HappyPT", "Antipetistas"))
pred_sd1antipt$model <- NA
pred_sd1antipt$model[is.na(pred_sd1antipt$model)] <- "Petistas"
pred_sd2antipt <- ggpredict(sd2antipt, terms = c("s.comp.HappyPT", "Antipetistas"))
pred_sd2antipt$model <- NA
pred_sd2antipt$model[is.na(pred_sd2antipt$model)] <- "Antipetistas"

pred_sdantipt <- rbind(pred_sd1antipt, pred_sd2antipt)%>% arrange(desc(model))
pred_sdantipt <- subset(pred_sdantipt, group==1)


plot_pred_sdantipt<- ggplot(pred_sdantipt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1.3,1)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Social Distance")+ylab("Dehumanization")+ggtitle("Social Distance - Evaluation by Antipetistas") 
 
plot_pred_sdantipt

#Putting them together: 

socialdistance<- ggarrange(plot_pred_sdpt, plot_pred_sdantipt,
  common.legend = T, legend = "bottom", nrow=1, ncol=2, 
      heights = c(5, 5)
  )
socialdistance

```

### Old Social distance
```{r socialdistance1, include=F}
## Blatant Against Petistas
emtrends(correlates, ~voting, var="s.comp.Happy")
emtrends(correlates, pairwise ~ voting, var="s.comp.Happy")
#plotting:
(mylist <- list(s.comp.Happy=seq(-1,1,by=0.25), voting=c("Bolsonaristas", "Antipetistas")))
socdistPT<- emmip(correlates, voting ~s.comp.Happy, at=mylist,CIs=TRUE, 
                  plotit=F)
socdistPT$voting <- factor(socdistPT$voting)
levels(socdistPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.socdistPT <- ggplot(data=socdistPT, aes(x=s.comp.Happy, y=yvar, 
                                       color=voting)) + geom_line()
p1.socdistPT  <- p.socdistPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Social Distance from Petistas")+
  ylab("Dehumanization of Petistas")+ylim(-1,1)
p1.socdistPT



## Blatant Against Antipetistas
emtrends(correlates1, ~voting, var="s.comp.Happy")
emtrends(correlates1, pairwise ~ voting, var="s.comp.Happy")
#plotting:
(mylist <- list(s.comp.Happy=seq(-1,1,by=0.25), voting=c("Lulistas", "Petistas")))
socdistAntiPT<- emmip(correlates1, voting ~s.comp.Happy, at=mylist,
                      CIs=TRUE, plotit=F)
socdistAntiPT$voting <- factor(socdistAntiPT$voting)
levels(socdistAntiPT$voting) <-c("Lulistas", "Petistas")
p.socdistAntiPT <- ggplot(data=socdistAntiPT, aes(x=s.comp.Happy, y=yvar, 
                                       color=voting)) + geom_line()
p1.socdistAntiPT  <- p.socdistAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  xlab("Social Distance from Antipetistas")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1)
p1.socdistAntiPT


socdist<- ggarrange(p1.socdistAntiPT, p1.socdistPT,
  common.legend = F, legend = "bottom", nrow=1
  )
socdist
```


### New Moral Distance
```{r newmoraldistance, include=T}

mean(main$s.comp.Morality, na.rm=T)

main %>%
    group_by(voting) %>%
    dplyr::summarize(Mean = mean(s.comp.Morality, na.rm=TRUE), SD=sd(s.comp.Morality, na.rm=T))

#pairwise t-tests of  s.comp.Morality by partisanship:
# where y is numeric and x is a binary factor
pwc <- main %>%
  rstatix::pairwise_t_test(s.comp.Morality ~ voting, p.adjust.method = "bonferroni")
pwc


#Evaluation by petistas

md1pt <- lm(s.BlatantDehum_1~s.comp.Happy*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(md1pt)

md2pt <- lm(s.BlatantDehum_2~s.comp.Happy*Petistas+s.comp.Morality*Petistas+s.comp.SDO*Petistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(md2pt)

pred_md1pt <- ggpredict(md1pt, terms = c("s.comp.Morality", "Petistas"))
pred_md1pt$model <- NA
pred_md1pt$model[is.na(pred_md1pt$model)] <- "Petistas"
pred_md2pt <- ggpredict(md2pt, terms = c("s.comp.Morality", "Petistas"))
pred_md2pt$model <- NA
pred_md2pt$model[is.na(pred_md2pt$model)] <- "Antipetistas"

pred_mdpt <- rbind(pred_md1pt, pred_md2pt)%>% arrange(desc(model))
pred_mdpt <- subset(pred_mdpt, group==1)


plot_pred_mdpt<- ggplot(pred_mdpt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1,1)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Moral Distance")+ylab("Dehumanization")+ggtitle("Moral Distance - Evaluation by Petistas")  

plot_pred_mdpt #Evaluations by petistas

#Evaluations by antipetistas

md1antipt <- lm(s.BlatantDehum_1~s.comp.Happy*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(md1antipt)

md2antipt <- lm(s.BlatantDehum_2~s.comp.Happy*Antipetistas+s.comp.Morality*Antipetistas+s.comp.SDO*Antipetistas+Age+Region+Race+Gender+Educ+HHIncome+Threat, main)
summary(md2antipt)

pred_md1antipt <- ggpredict(md1antipt, terms = c("s.comp.Morality", "Antipetistas"))
pred_md1antipt$model <- NA
pred_md1antipt$model[is.na(pred_md1antipt$model)] <- "Petistas"
pred_md2antipt <- ggpredict(md2antipt, terms = c("s.comp.Morality", "Antipetistas"))
pred_md2antipt$model <- NA
pred_md2antipt$model[is.na(pred_md2antipt$model)] <- "Antipetistas"

pred_mdantipt <- rbind(pred_md1antipt, pred_md2antipt)%>% arrange(desc(model))
pred_mdantipt <- subset(pred_mdantipt, group==1)


plot_pred_mdantipt<- ggplot(pred_mdantipt, aes(x, predicted, color=model)) + geom_point(aes(color=model))+ylim(-1,1)+
  geom_line(aes(color=model))+ 
  geom_pointrange(aes(ymax=conf.high, ymin=conf.low, color=model), size=0.2)+
  theme_bw(base_size=8)+
  scale_color_grey(start=0.8, end=0, name = "Targeted Groups")+
  xlab("Moral Distance")+ylab("Dehumanization")+ggtitle("Moral Distance - Evaluation by Antipetistas") 
 
plot_pred_mdantipt

#Putting them together: 

moraldistance<- ggarrange(plot_pred_mdpt, plot_pred_mdantipt,
  common.legend = T, legend = "bottom", nrow=1, ncol=2, 
      heights = c(5, 5)
  )
moraldistance
```

### Old Moral distance
```{r moraldistance1, include=F}
#######################################################################

## Blatant Against Petistas
correlates <- lm(s.BlatantDehum_1~s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(correlates)

emtrends(correlates, ~voting, var="s.comp.Morality")
emtrends(correlates, pairwise ~ voting, var="s.comp.Morality")
#plotting:
(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), voting=c("Bolsonaristas","Antipetistas")))
mordistPT <- emmip(correlates, voting ~s.comp.Morality, at=mylist, CIs=TRUE, plotit=F)

mordistPT$voting <- factor(mordistPT$voting)
levels(mordistPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.mordistPT <- ggplot(data=mordistPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=voting)) + geom_line()
p1.mordistPT  <- p.mordistPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Moral Distance")+
  ylab("Dehumanization of Petistas")+ylim(-1,1)
p1.mordistPT

(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), voting=c("Lulistas","Petistas")))
mordistPT <- emmip(correlates, voting ~s.comp.Morality, at=mylist, CIs=TRUE, plotit=F)
mordistPT$voting <- factor(mordistPT$voting)
levels(mordistPT$voting) <-c("Lulistas","Petistas")
p.mordistPT <- ggplot(data=mordistPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=voting)) + geom_line()
p2.mordistPT  <- p.mordistPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  xlab("Moral Distance")+
  ylab("Dehumanization of Petistas")+ylim(-1,1)
p2.mordistPT


## Blatant Against Antipetistas
emtrends(correlates1, ~voting, var="s.comp.Morality")
emtrends(correlates1, pairwise ~ voting, var="s.comp.Morality")
#plotting:
(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), voting=c("Bolsonaristas", "Antipetistas")))
mordistAntiPT<- emmip(correlates1, voting ~s.comp.Morality, at=mylist,
                      CIs=TRUE, plotit=F)

mordistAntiPT$voting<- factor(mordistAntiPT$voting)
levels(mordistAntiPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.mordistAntiPT <- ggplot(data=mordistAntiPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=voting)) + geom_line()
p1.mordistAntiPT  <- p.mordistAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Moral Distance")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1)
p1.mordistAntiPT

(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), voting=c("Lulistas", "Petistas")))
mordistAntiPT<- emmip(correlates1, voting ~s.comp.Morality, at=mylist,
                      CIs=TRUE, plotit=F)

mordistAntiPT$voting<- factor(mordistAntiPT$voting)
levels(mordistAntiPT$voting) <-c("Lulistas", "Petistas")
p.mordistAntiPT <- ggplot(data=mordistAntiPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=voting)) + geom_line()
p2.mordistAntiPT  <- p.mordistAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  xlab("Moral Distance")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1)
p2.mordistAntiPT


mordist<- ggarrange(p2.mordistPT,p1.mordistPT,p2.mordistAntiPT,p1.mordistAntiPT,
  common.legend = F, legend = "bottom", nrow=2, ncol=2, 
      heights = c(5, 5)
  )
mordist

```


### Network perceptions


```{r network, include=T}
#Perceptions about a segregated or integrated society
#network variable scale: 0=segregated network; 10=integrated network
summary(as.numeric(main$Network_1))

main$s.comp.Network <- rescale(as.numeric(main$Network_1), to=c(-1,1))
summary(main$s.comp.Network)

#Means
mean(main$s.comp.Network, na.rm=T)

main %>%
    group_by(voting) %>%
    dplyr::summarize(Mean = mean(s.comp.Network, na.rm=TRUE))

#pairwise t-tests of  s.comp.SDO by partisanship:
# where y is numeric and x is a binary factor
pwc <- main %>%
  rstatix::pairwise_t_test(s.comp.Network ~ voting, p.adjust.method = "bonferroni")
pwc


#AGAISNT PETISTAS

net1 <- lm(s.BlatantDehum_1~s.comp.Network*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(net1)
emtrends(net1, ~voting, var="s.comp.Network")
emtrends(net1, pairwise ~ voting, var="s.comp.Network")

#plotting:
(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), voting=c("Bolsonaristas", "Antipetistas")))
netPT <- emmip(net1, voting ~s.comp.Network, at=mylist,
                   CIs=TRUE, plotit=F)

netPT$voting <- factor(netPT$voting)
levels(netPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.netPT <- ggplot(data=netPT, aes(x=s.comp.Network, y=yvar, 
                                       color=voting)) + geom_line()
p1.netPT  <- p.netPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Petistas")+ylim(-1,1.3)
p1.netPT


(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), voting=c("Lulistas", "Petistas")))
netPT <- emmip(net1, voting ~s.comp.Network, at=mylist,
                   CIs=TRUE, plotit=F)

netPT$voting <- factor(netPT$voting)
levels(netPT$voting) <-c("Lulistas", "Petistas")
p.netPT <- ggplot(data=netPT, aes(x=s.comp.Network, y=yvar, 
                                       color=voting)) + geom_line()
p2.netPT  <- p.netPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Petistas")+ylim(-1,1)
p2.netPT

# AGAIST ANTIPETISTAS
net2 <- lm(s.BlatantDehum_2~s.comp.Network*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(net2)
emtrends(net2, ~voting, var="s.comp.Network")
emtrends(net2, pairwise ~ voting, var="s.comp.Network")

#plotting:
(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), voting=c("Bolsonaristas","Antipetistas")))
netAntiPT <- emmip(net2, voting ~s.comp.Network, at=mylist,
                   CIs=TRUE, plotit=F)

netAntiPT$voting <- factor(netAntiPT$voting)
levels(netAntiPT$voting) <-c("Bolsonaristas", "Antipetistas")
p.netAntiPT <- ggplot(data=netAntiPT, aes(x=s.comp.Network, y=yvar, color=voting)) + geom_line()
p1.netAntiPT  <- p.netAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Antipetistas")+ylim(-1,1)
p1.netAntiPT

(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), voting=c("Lulistas","Petistas")))
netAntiPT <- emmip(net2, voting ~s.comp.Network, at=mylist,
                   CIs=TRUE, plotit=F)

netAntiPT$voting <- factor(netAntiPT$voting)
levels(netAntiPT$voting) <-c("Lulistas", "Petistas")
p.netAntiPT <- ggplot(data=netAntiPT, aes(x=s.comp.Network, y=yvar, color=voting)) + geom_line()
p2.netAntiPT  <- p.netAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.4, end=0, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Antipetistas")+ylim(-1,1)
p2.netAntiPT

p.net<- ggarrange(p2.netPT,p1.netPT,p2.netAntiPT,p1.netAntiPT,
  common.legend = F, legend = "bottom",nrow=2, ncol=2,heights = c(5, 5) 
  )
p.net

```



## Spliting results of correlates by partisan strngth

```{r strength_correlates, include=F}


# STRONG PARTISAN ID
summary(main$s.comp.Petismo)
summary(main$s.comp.Antipetismo)
main$strength <- NA
main$strength[main$s.comp.Petismo>0.3] <-"Strong_Petistas"
main$strength[main$s.comp.Antipetismo>0.1] <-"Strong_Antipetistas"
main$strength[main$s.comp.Petismo<=0.3] <-"Weak_Petistas"
main$strength[main$s.comp.Antipetismo<=0.1] <-"Weak_Antipetistas"
prop.table(table(main$strength))  

#Blatant against PT
strengthcorrelates <- lm(s.BlatantDehum_1~s.comp.Happy*strength+ s.comp.Morality*strength+s.comp.SDO*strength+s.comp.Network*strength+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(strengthcorrelates)  
  
## SOCIAL DISTANCE
emtrends(strengthcorrelates, ~strength, var="s.comp.Happy")
emtrends(strengthcorrelates, pairwise ~ strength, var="s.comp.Happy")
#plotting:
(mylist <- list(s.comp.Happy=seq(-1,1,by=0.25), strength=c("Strong_Antipetistas", "Weak_Antipetistas")))
strgsocdistPT<- emmip(strengthcorrelates, strength ~s.comp.Happy, at=mylist,CIs=TRUE, 
                  plotit=F)
strgsocdistPT$strength <- factor(strgsocdistPT$strength)
levels(strgsocdistPT$strength) <-c("Strong_Antipetistas", "Weak_Antipetistas")
p.strgsocdistPT <- ggplot(data=strgsocdistPT, aes(x=s.comp.Happy, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgsocdistPT  <- p.strgsocdistPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Social Distance from Petistas")+
  ylab("Dehumanization of Petistas")+ylim(-1,1.8)
p1.strgsocdistPT


#Blatant against AntiPT
strengthcorrelates1 <- lm(s.BlatantDehum_2~s.comp.Happy*strength+ s.comp.Morality*strength+s.comp.SDO*strength+s.comp.Network*strength+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(strengthcorrelates1)  
  
## SOCIAL DISTANCE
emtrends(strengthcorrelates1, ~strength, var="s.comp.Happy")
emtrends(strengthcorrelates1, pairwise ~ strength, var="s.comp.Happy")
#plotting:
(mylist <- list(s.comp.Happy=seq(-1,1,by=0.25), strength=c("Strong_Petistas", "Weak_Petistas")))
strgsocdistAntiPT<- emmip(strengthcorrelates1, strength ~s.comp.Happy, at=mylist,CIs=TRUE, 
                  plotit=F)
strgsocdistAntiPT$strength <- factor(strgsocdistAntiPT$strength)
levels(strgsocdistAntiPT$strength) <-c("Strong_Petistas", "Weak_Petistas")
p.strgsocdistAntiPT <- ggplot(data=strgsocdistAntiPT, aes(x=s.comp.Happy, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgsocdistAntiPT  <- p.strgsocdistAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.4, name="Partisanship")+ 
  xlab("Social Distance from Antipetistas")+
  ylab("Dehumanization of Antipetistas")+ylim(-1,1.8)
p1.strgsocdistAntiPT

# MORAL DISTANCE
#Blantant against Petistas
emtrends(strengthcorrelates, ~strength, var="s.comp.Morality")
emtrends(strengthcorrelates, pairwise ~ strength, var="s.comp.Morality")
#plotting:
(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), strength=c("Strong_Antipetistas", "Weak_Antipetistas")))
strgmordistPT<- emmip(strengthcorrelates, strength ~s.comp.Morality, at=mylist,CIs=TRUE, 
                  plotit=F)
strgmordistPT$strength <- factor(strgmordistPT$strength)
levels(strgmordistPT$strength) <-c("Strong_Antipetistas", "Weak_Antipetistas")
p.strgmordistPT <- ggplot(data=strgmordistPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgmordistPT  <- p.strgmordistPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Moral Distance from Petistas")+
  ylab("Dehumanization of Petistas")+ylim(-1,1.8)
p1.strgmordistPT


#Blatant against AntiPT
strengthcorrelates1 <- lm(s.BlatantDehum_2~s.comp.Happy*strength+ s.comp.Morality*strength+s.comp.SDO*strength+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(strengthcorrelates1)  
  
emtrends(strengthcorrelates1, ~strength, var="s.comp.Morality")
emtrends(strengthcorrelates1, pairwise ~ strength, var="s.comp.Morality")
#plotting:
(mylist <- list(s.comp.Morality=seq(-1,1,by=0.25), strength=c("Strong_Petistas", "Weak_Petistas")))
strgmordistAntiPT<- emmip(strengthcorrelates1, strength ~s.comp.Morality, at=mylist,CIs=TRUE, 
                  plotit=F)
strgmordistAntiPT$strength <- factor(strgmordistAntiPT$strength)
levels(strgmordistAntiPT$strength) <-c("Strong_Petistas", "Weak_Petistas")
p.strgmordistAntiPT <- ggplot(data=strgmordistAntiPT, aes(x=s.comp.Morality, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgmordistAntiPT  <- p.strgmordistAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.4, name="Partisanship")+ 
  xlab("Moral Distance from Antipetistas")+
  ylab("Dehumanization of Antipetistas")+ylim(-1,1.8)
p1.strgmordistAntiPT



# Network
#Blantant against Petistas
emtrends(strengthcorrelates, ~strength, var="s.comp.Network")
emtrends(strengthcorrelates, pairwise ~ strength, var="s.comp.Network")
#plotting:
(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), strength=c("Strong_Antipetistas", "Weak_Antipetistas")))
strgnetPT<- emmip(strengthcorrelates, strength ~s.comp.Network, at=mylist,CIs=TRUE, 
                  plotit=F)
strgnetPT$strength <- factor(strgnetPT$strength)
levels(strgnetPT$strength) <-c("Strong_Antipetistas", "Weak_Antipetistas")
p.strgnetPT <- ggplot(data=strgnetPT, aes(x=s.comp.Network, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgnetPT  <- p.strgnetPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Petistas")+ylim(-1,1.3)
p1.strgnetPT


#Blatant against AntiPT
strengthcorrelates1 <- lm(s.BlatantDehum_2~s.comp.Happy*strength+ s.comp.Morality*strength+s.comp.SDO*strength+s.comp.Network*strength+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(strengthcorrelates1)  
  
emtrends(strengthcorrelates1, ~strength, var="s.comp.Network")
emtrends(strengthcorrelates1, pairwise ~ strength, var="s.comp.Network")
#plotting:
(mylist <- list(s.comp.Network=seq(-1,1,by=0.25), strength=c("Strong_Petistas", "Weak_Petistas")))
strgnetAntiPT<- emmip(strengthcorrelates1, strength ~s.comp.Network, at=mylist,CIs=TRUE, 
                  plotit=F)
strgnetAntiPT$strength <- factor(strgnetAntiPT$strength)
levels(strgnetAntiPT$strength) <-c("Strong_Petistas", "Weak_Petistas")
p.strgnetAntiPT <- ggplot(data=strgnetAntiPT, aes(x=s.comp.Network, y=yvar, 
                                       color=strength)) + geom_line()
p1.strgnetAntiPT  <- p.strgnetAntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, color=strength), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.4, name="Partisanship")+ 
  xlab("Network Perception")+
  ylab("Dehumanization of Antipetistas")+ylim(-1,1.3)
p1.strgnetAntiPT



#NETWORK PERCEPTIONS
#Partisan strength means

means_strength<- main %>% group_by(strength) %>%
    dplyr::summarize(Mean = mean(s.comp.Network, na.rm=TRUE))

#pairwise t-tests of  s.comp.SDO by partisanship:
# where y is numeric and x is a binary factor
pwc <- main %>%
  rstatix::pairwise_t_test(s.comp.Network ~ strength, p.adjust.method = "bonferroni")
pwc





```




## Feelings about Lula/Bolsonaro
```{r feelings, include=F}

table(main$Q81, main$voting) # feelings about Lula
table(main$Q82, main$voting) # feelings about Bolsonaro

#scale: feel bad to feel good about Lula
main$Q81 <- as.numeric(factor(main$Q81, levels=c("Muito mal", "Mal", "Indiferente", 
                                      "Bem", "Muito bem")))
summary(main$Q81)
main$s.Q81 <- rescale(main$Q81, to = c(-1, 1))
summary(main$s.Q81)

#scale: feel bad to feel good about Bolsonaro
main$Q82 <- as.numeric(factor(main$Q82, levels=c("Muito mal", "Mal", "Indiferente", 
                                      "Bem", "Muito bem")))
summary(main$Q82)
main$s.Q82 <- rescale(main$Q82, to = c(-1, 1))
summary(main$s.Q82)

#our sample on average feel better about Lula than about Bolsonaro

#blatant dehumanization about petistas
##feelings about Lula
feelings1 <- lm(s.BlatantDehum_1~s.Q81*voting+s.Q82*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(feelings1)
emtrends(feelings1, ~voting, var="s.Q81")
emtrends(feelings1, pairwise ~ voting, var="s.Q81")

###leftists
(mylist <- list(s.Q81=seq(-1,1,by=0.25), voting=c("Petistas", "Lulistas", "NonPartisans2")))
feelings_PT <- emmip(feelings1, voting ~s.Q81, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_PT$voting <- factor(feelings_PT$voting)
levels(feelings_PT$voting) <-c("Petistas", "Lulistas", "NonPartisans2")
p.feelings_PT <- ggplot(data=feelings_PT, aes(x=s.Q81, y=yvar, color=voting)) + geom_line()
p1.feelings_PT  <- p.feelings_PT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.6)+ 
  xlab("Feelings about Lula")+
  ylab("Dehumanization of Petistas")+ylim(-1.2,1.2)
p1.feelings_PT

###rightists

(mylist <- list(s.Q81=seq(-1,1,by=0.25), voting=c("NonPartisans2", "Bolsonaristas","Antipetistas")))
feelings_PT <- emmip(feelings1, voting ~s.Q81, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_PT$voting <- factor(feelings_PT$voting)
levels(feelings_PT$voting) <-c("NonPartisans2", "Bolsonaristas", "Antipetistas")
p.feelings_PT <- ggplot(data=feelings_PT, aes(x=s.Q81, y=yvar, color=voting)) + geom_line()
p2.feelings_PT  <- p.feelings_PT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8)+ 
  xlab("Feelings about Lula")+
  ylab("Dehumanization of Petistas")+ylim(-1.2,1.2)
p2.feelings_PT

##feelings about Bolsonaro
feelings1 <- lm(s.BlatantDehum_1~s.Q81*voting+s.Q82*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(feelings1)
emtrends(feelings1, ~voting, var="s.Q82")
emtrends(feelings1, pairwise ~ voting, var="s.Q82")

###leftists
(mylist <- list(s.Q82=seq(-1,1,by=0.25), voting=c("Petistas", "Lulistas", "NonPartisans2")))
feelings_PT <- emmip(feelings1, voting ~s.Q82, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_PT$voting <- factor(feelings_PT$voting)
levels(feelings_PT$voting) <-c("Petistas", "Lulistas", "NonPartisans2")
p.feelings_PT <- ggplot(data=feelings_PT, aes(x=s.Q82, y=yvar, color=voting)) + geom_line()
p3.feelings_PT  <- p.feelings_PT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.6)+ 
  xlab("Feelings about Bolsonaro")+
  ylab("Dehumanization of Petistas")+ylim(-1.2,1.2)
p3.feelings_PT

###rightists

(mylist <- list(s.Q82=seq(-1,1,by=0.25), voting=c("NonPartisans2", "Bolsonaristas","Antipetistas")))
feelings_PT <- emmip(feelings1, voting ~s.Q82, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_PT$voting <- factor(feelings_PT$voting)
levels(feelings_PT$voting) <-c("NonPartisans2", "Bolsonaristas", "Antipetistas")
p.feelings_PT <- ggplot(data=feelings_PT, aes(x=s.Q82, y=yvar, color=voting)) + geom_line()
p4.feelings_PT  <- p.feelings_PT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8)+ 
  xlab("Feelings about Bolsonaro")+
  ylab("Dehumanization of Petistas")+ylim(-1.2,1.2)
p4.feelings_PT

plot_feelings_PT<- ggarrange(p1.feelings_PT,p2.feelings_PT,p3.feelings_PT,p4.feelings_PT,
  common.legend = F, legend = "bottom", nrow=2, ncol=2
  )
plot_feelings_PT


#blatant dehumanization about antipetistas
##feelings about Lula
feelings1 <- lm(s.BlatantDehum_2~s.Q81*voting+s.Q82*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(feelings1)
emtrends(feelings1, ~voting, var="s.Q81")
emtrends(feelings1, pairwise ~ voting, var="s.Q81")

###leftists
(mylist <- list(s.Q81=seq(-1,1,by=0.25), voting=c("Petistas", "Lulistas", "NonPartisans2")))
feelings_AntiPT <- emmip(feelings1, voting ~s.Q81, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_AntiPT$voting <- factor(feelings_AntiPT$voting)
levels(feelings_AntiPT$voting) <-c("Petistas", "Lulistas", "NonPartisans2")
p.feelings_AntiPT <- ggplot(data=feelings_AntiPT, aes(x=s.Q81, y=yvar, color=voting)) + geom_line()
p1.feelings_AntiPT  <- p.feelings_AntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.6)+ 
  xlab("Feelings about Lula")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1.2)
p1.feelings_AntiPT

###rightists

(mylist <- list(s.Q81=seq(-1,1,by=0.25), voting=c("NonPartisans2", "Bolsonaristas","Antipetistas")))
feelings_AntiPT <- emmip(feelings1, voting ~s.Q81, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_AntiPT$voting <- factor(feelings_AntiPT$voting)
levels(feelings_AntiPT$voting) <-c("NonPartisans2", "Bolsonaristas", "Antipetistas")
p.feelings_AntiPT <- ggplot(data=feelings_AntiPT, aes(x=s.Q81, y=yvar, color=voting)) + geom_line()
p2.feelings_AntiPT  <- p.feelings_AntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8)+ 
  xlab("Feelings about Lula")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1.2)
p2.feelings_AntiPT

##feelings about Bolsonaro
feelings1 <- lm(s.BlatantDehum_2~s.Q81*voting+s.Q82*voting+s.comp.Happy*voting+ s.comp.Morality*voting+s.comp.SDO*voting+Age+Region+Gender+Race+Educ+HHIncome+Threat, main)
summary(feelings1)
emtrends(feelings1, ~voting, var="s.Q82")
emtrends(feelings1, pairwise ~ voting, var="s.Q82")

###leftists
(mylist <- list(s.Q82=seq(-1,1,by=0.25), voting=c("Petistas", "Lulistas", "NonPartisans2")))
feelings_AntiPT <- emmip(feelings1, voting ~s.Q82, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_AntiPT$voting <- factor(feelings_AntiPT$voting)
levels(feelings_AntiPT$voting) <-c("Petistas", "Lulistas", "NonPartisans2")
p.feelings_AntiPT <- ggplot(data=feelings_AntiPT, aes(x=s.Q82, y=yvar, color=voting)) + geom_line()
p3.feelings_AntiPT  <- p.feelings_AntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0, end=0.6)+ 
  xlab("Feelings about Bolsonaro")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1.2)
p3.feelings_AntiPT

###rightists

(mylist <- list(s.Q82=seq(-1,1,by=0.25), voting=c("NonPartisans2", "Bolsonaristas","Antipetistas")))
feelings_AntiPT <- emmip(feelings1, voting ~s.Q82, at=mylist,
                   CIs=TRUE, plotit=F)

feelings_AntiPT$voting <- factor(feelings_AntiPT$voting)
levels(feelings_AntiPT$voting) <-c("NonPartisans2", "Bolsonaristas", "Antipetistas")
p.feelings_AntiPT <- ggplot(data=feelings_AntiPT, aes(x=s.Q82, y=yvar, color=voting)) + geom_line()
p4.feelings_AntiPT  <- p.feelings_AntiPT+ 
  geom_pointrange(aes(ymax=UCL, ymin=LCL, fill=voting), size=0.2)+
  theme_bw(base_size=8)+scale_color_grey(start=0.6, end=0.8)+ 
  xlab("Feelings about Bolsonaro")+
  ylab("Dehumanization of Antipetistas")+ylim(-1.2,1.2)
p4.feelings_AntiPT

plot_feelings_AntiPT<- ggarrange(p1.feelings_AntiPT,p2.feelings_AntiPT,p3.feelings_AntiPT,p4.feelings_AntiPT,
  common.legend = F, legend = "bottom", nrow=2, ncol=2
  )
plot_feelings_AntiPT




```




# Tables for the Appendix

```{r tables_appendix, include=T, results='asis'}

# SUMMARY STATISTICS

# summary dependent variables
stargazer(main[c("s.BlatantDehum_1", "s.BlatantDehum_2", "s.BlatantDehum_3")], 
          out="summary_dv.tex", 
          title="Summary Statistics for Dependent Variables", digits=2)

#independent variables
main$f.gender <- as.factor(main$Gender)
str(main$f.gender)
main$f.region <- as.factor(main$Region)
str(main$f.region)
main$f.race <- as.factor(main$Race)
str(main$f.race)
main$f.race <- as.factor(main$Race)
str(main$f.race)
main$f.educ <- as.factor(main$Educ)
str(main$f.educ)
main$f.hhincome <- as.factor(main$HHIncome)
str(main$f.hhincome)
main$f.threat <- as.factor(main$Threat)
str(main$f.threat)
main$f.age <- as.factor(main$Age)
str(main$f.age)
library(fastDummies)
main <- main %>% dummy_cols(select_columns = c("f.gender", "f.region", "f.race", "f.educ", "f.hhincome", "f.threat", "f.age"))
stargazer(main[c("Petistas", "Antipetistas", "NonPartisans2", "Lulistas","Bolsonaristas", "s.comp.Petismo", "s.comp.Antipetismo", "s.comp.Happy", "s.comp.HappyPT", "s.comp.HappyAntiPT", "s.comp.Morality", "s.comp.SDO", "f.gender_Man", "f.gender_Woman", "f.region_Midwest", "f.region_North",   "f.region_Northeast","f.region_South","f.region_Southeast", "f.race_Black","f.race_Brown", "f.race_Indigenous",  "f.race_White", "f.race_Yellow", "f.educ_College", "f.educ_Elementary School", "f.educ_Grad School", "f.educ_High School", "f.educ_Middle School", "f.hhincome_Até R$ 1.212,00","f.hhincome_De R$ 1.212,01 até R$ 2.424,00","f.hhincome_De R$ 2.424,01 até R$ 4.848,00", "f.hhincome_De R$4.848,01 até R$ 9.696,00","f.hhincome_De R$9.696,01 até R$19.392,00", "f.hhincome_Mais de R$19.392,01","f.age","f.age_18-29","f.age_30-39","f.age_40-49","f.age_50-59","f.age_60 ou mais", "f.threat_Control" ,"f.threat_Threat_APT", "f.threat_Threat_PT")], 
          out="summary_iv.tex", 
          title="Summary Statistics for Independent Variables", 
          digits=2)

##ATENÇÃO!!! Abaixo: nao usar as regressoes com standardized regression coefficients - tables are generated with wrong significance level for coefficients.

#Figure Blatant
stargazer(ksblat1, ksblat2, ksblat3,  title="Regression Results of Figure 2", digits=2,dep.var.labels=c("Dehumanization ag. PT", "Dehumanization ag. AntiPT", "Dehumanization ag. Nonpartisans"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")

#Figure Blatant+pure+pl antipetistas
stargazer(pksblat1, pksblat2, pksblat3,  title="Regression Results of Figure 2, adapted to include Pure Antipetistas and PL Antipetistas", digits=2,dep.var.labels=c("Dehumanization ag. PT", "Dehumanization ag. AntiPT", "Dehumanization ag. Nonpartisans"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")


# Figure 3
stargazer(ksblat1_pt, ksblat2_pt,  title="Regression Results of Figure 3", digits=2,dep.var.labels=c("Dehumanization ag. PT", "Dehumanization ag. AntiPT"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")


#stargazer(blatPT_idstrength, title="Regression Results of Figure 3", digits=2, dep.var.labels = c("Blatant"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")

# Figure 4
stargazer(ksblat1_antipt, ksblat2_antipt,  title="Regression Results of Figure 4", digits=2,dep.var.labels=c("Dehumanization ag. PT", "Dehumanization ag. AntiPT"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")


#Figure 5A
stargazer(control_blat1, control_blat2, control_blat3, title="Regression Results of Figure 5A - Survey ran in April 2023", digits=2, dep.var.labels =c( "Petistas", "Antipetistas", "Nonpartisans"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")

#Figure 5B - convert regression models into list 

stargazer(Threat_APT_blat1, Threat_APT_blat2, Threat_APT_blat3, title="Regression Results of Figure 5B - Survey ran in April 2023", digits=2, dep.var.labels =c( "Petistas", "Antipetistas", "Nonpartisans"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")

#Figure 5C - convert regression models into list (they are tibbles)
stargazer(Threat_PT_blat1, Threat_PT_blat2, Threat_PT_blat3, title="Regression Results of Figure 5C - Survey ran in April 2023", digits=2, dep.var.labels =c( "Petistas", "Antipetistas", "Nonpartisans"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")


#Figures 6,7,8 - Evaluation by petistas
stargazer(sdo1pt, sdo2pt,  title="Regression Results of Figures 6,7, and 8", digits=2, dep.var.labels =c( "Petistas", "Antipetistas"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")

#Figures 6,7,8 - Evaluation by antipetistas
stargazer(sdo1antipt, sdo2antipt, title="Regression Results of Figures 6,7, and 8", digits=2, dep.var.labels =c( "Petistas", "Antipetistas"), single.row = TRUE,  no.space = TRUE,  column.sep.width = "3pt", font.size = "small")


#Correlation

correlation.matrix <- cor(main[c("s.BlatantDehum_1","s.BlatantDehum_2","s.BlatantDehum_3","s.comp.Petismo","s.comp.Antipetismo","s.comp.Happy","s.comp.HappyAntiPT","s.comp.HappyPT","s.comp.Morality","s.comp.SDO")], use= "pairwise.complete.obs")


stargazer(correlation.matrix, header=FALSE, title="Correlation Matrix", dep.var.labels.include=FALSE, covariate.labels= c("BlatantPT", "BlatantAntiPT", "BlatantNonpartisan", "PTpartisanship", "AntiPTpartisanship", "SocialDistance", "SocialDistancePT", "SocialDistanceAntiPT", "MoralDistance", "SDO"), digits=2, single.row = TRUE, no.space = TRUE,  column.sep.width = "1pt", font.size = "small")

#dep.var.labels= c("", "BlatantPT", "BlatantAntiPT", "BlatantNonpartisan", "AnimalisticPT", "AnimalisticAntiPT", "AnimalisticNonpartisan", "MechanisticPT", "MechanisticAntiPT", "MechanisticNonpartisans", "StrengthPT", "StrengthAntiPT", "SocialDistance", "SocialDistancePT", "SocialDistanceAntiPT", "MoralDistance", "SDO")

```
